mirror of
				https://projects.vdr-developer.org/git/vdr-plugin-skindesigner.git
				synced 2023-10-19 15:58:31 +00:00 
			
		
		
		
	optimized image caching code
This commit is contained in:
		@@ -46,25 +46,24 @@ void cImageCache::CacheLogo(int width, int height) {
 | 
				
			|||||||
    if (width == 0 || height == 0)
 | 
					    if (width == 0 || height == 0)
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    int channelsCached = 0;     
 | 
					    int logosCached = 0;     
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    for (const cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) {
 | 
					    for (const cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) {
 | 
				
			||||||
        if (channelsCached >= config.numLogosPerSizeInitial)
 | 
					        if (logosCached >= config.numLogosPerSizeInitial)
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        if (channel->GroupSep()) {
 | 
					        if (channel->GroupSep()) {
 | 
				
			||||||
            continue;
 | 
					            continue;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        stringstream logoName;
 | 
				
			||||||
 | 
					        logoName << *channel->GetChannelID().ToString() << "_" << width << "x" << height;
 | 
				
			||||||
 | 
					        map<string, cImage*>::iterator hit = channelLogoCache.find(logoName.str());
 | 
				
			||||||
 | 
					        if (hit != channelLogoCache.end()) {
 | 
				
			||||||
 | 
					            continue;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        bool success = LoadLogo(channel);
 | 
					        bool success = LoadLogo(channel);
 | 
				
			||||||
        if (success) {
 | 
					        if (success) {
 | 
				
			||||||
            channelsCached++;
 | 
					            logosCached++;
 | 
				
			||||||
            cImage *image = CreateImage(width, height);
 | 
					            cImage *image = CreateImage(width, height);
 | 
				
			||||||
            stringstream logoName;
 | 
					 | 
				
			||||||
            logoName << *channel->GetChannelID().ToString() << "_" << width << "x" << height;
 | 
					 | 
				
			||||||
            std::map<std::string, cImage*>::iterator hit = channelLogoCache.find(logoName.str());
 | 
					 | 
				
			||||||
            if (hit != channelLogoCache.end()) {
 | 
					 | 
				
			||||||
                delete image;
 | 
					 | 
				
			||||||
                return;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            channelLogoCache.insert(pair<string, cImage*>(logoName.str(), image));
 | 
					            channelLogoCache.insert(pair<string, cImage*>(logoName.str(), image));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -158,13 +157,7 @@ bool cImageCache::SeparatorLogoExists(string name) {
 | 
				
			|||||||
void cImageCache::CacheIcon(eImageType type, string name, int width, int height) {
 | 
					void cImageCache::CacheIcon(eImageType type, string name, int width, int height) {
 | 
				
			||||||
    if (width < 1 || width > 1920 || height < 1 || height > 1080)
 | 
					    if (width < 1 || width > 1920 || height < 1 || height > 1080)
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    bool success = LoadIcon(type, name);
 | 
					    GetIcon(type, name, width, height);
 | 
				
			||||||
    if (!success) 
 | 
					 | 
				
			||||||
        return;
 | 
					 | 
				
			||||||
    stringstream iconName;
 | 
					 | 
				
			||||||
    iconName << name << "_" << width << "x" << height;
 | 
					 | 
				
			||||||
    cImage *image = CreateImage(width, height, true);
 | 
					 | 
				
			||||||
    iconCache.insert(pair<string, cImage*>(iconName.str(), image));
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cImage *cImageCache::GetIcon(eImageType type, string name, int width, int height) {
 | 
					cImage *cImageCache::GetIcon(eImageType type, string name, int width, int height) {
 | 
				
			||||||
@@ -281,13 +274,7 @@ bool cImageCache::MenuIconExists(string name) {
 | 
				
			|||||||
void cImageCache::CacheSkinpart(string name, int width, int height) {
 | 
					void cImageCache::CacheSkinpart(string name, int width, int height) {
 | 
				
			||||||
    if (width < 1 || width > 1920 || height < 1 || height > 1080)
 | 
					    if (width < 1 || width > 1920 || height < 1 || height > 1080)
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    bool success = LoadSkinpart(name);
 | 
					    GetSkinpart(name, width, height);
 | 
				
			||||||
    if (!success) 
 | 
					 | 
				
			||||||
        return;
 | 
					 | 
				
			||||||
    stringstream iconName;
 | 
					 | 
				
			||||||
    iconName << name << "_" << width << "x" << height;
 | 
					 | 
				
			||||||
    cImage *image = CreateImage(width, height, false);
 | 
					 | 
				
			||||||
    skinPartsCache.insert(pair<string, cImage*>(iconName.str(), image));
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cImage *cImageCache::GetSkinpart(string name, int width, int height) {
 | 
					cImage *cImageCache::GetSkinpart(string name, int width, int height) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -104,7 +104,6 @@ vector< pair<string, int> > cTemplate::GetUsedFonts(void) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void cTemplate::CacheImages(void) {
 | 
					void cTemplate::CacheImages(void) {
 | 
				
			||||||
    CacheImages(rootView);
 | 
					    CacheImages(rootView);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    rootView->InitSubViewIterator();
 | 
					    rootView->InitSubViewIterator();
 | 
				
			||||||
    cTemplateView *subView = NULL;
 | 
					    cTemplateView *subView = NULL;
 | 
				
			||||||
    while(subView = rootView->GetNextSubView()) {
 | 
					    while(subView = rootView->GetNextSubView()) {
 | 
				
			||||||
@@ -113,9 +112,7 @@ void cTemplate::CacheImages(void) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void cTemplate::Debug(void) {
 | 
					void cTemplate::Debug(void) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
    rootView->Debug();
 | 
					    rootView->Debug();
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*******************************************************************
 | 
					/*******************************************************************
 | 
				
			||||||
@@ -213,13 +210,7 @@ void cTemplate::CacheImages(cTemplateView *view) {
 | 
				
			|||||||
        viewElement->InitIterator();
 | 
					        viewElement->InitIterator();
 | 
				
			||||||
        cTemplatePixmap *pix = NULL;
 | 
					        cTemplatePixmap *pix = NULL;
 | 
				
			||||||
        while(pix = viewElement->GetNextPixmap()) {
 | 
					        while(pix = viewElement->GetNextPixmap()) {
 | 
				
			||||||
            pix->InitIterator();
 | 
					            CachePixmapImages(pix);
 | 
				
			||||||
            cTemplateFunction *func = NULL;
 | 
					 | 
				
			||||||
            while(func = pix->GetNextFunction()) {
 | 
					 | 
				
			||||||
                if (func->GetType() == ftDrawImage) {
 | 
					 | 
				
			||||||
                    CacheImage(func);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    //used images in viewLists pixmaps
 | 
					    //used images in viewLists pixmaps
 | 
				
			||||||
@@ -229,40 +220,40 @@ void cTemplate::CacheImages(cTemplateView *view) {
 | 
				
			|||||||
        viewList->InitIterator();
 | 
					        viewList->InitIterator();
 | 
				
			||||||
        cTemplatePixmap *pix = NULL;
 | 
					        cTemplatePixmap *pix = NULL;
 | 
				
			||||||
        while(pix = viewList->GetNextPixmap()) {
 | 
					        while(pix = viewList->GetNextPixmap()) {
 | 
				
			||||||
            pix->InitIterator();
 | 
					            CachePixmapImages(pix);
 | 
				
			||||||
            cTemplateFunction *func = NULL;
 | 
					 | 
				
			||||||
            while(func = pix->GetNextFunction()) {
 | 
					 | 
				
			||||||
                if (func->GetType() == ftDrawImage) {
 | 
					 | 
				
			||||||
                    CacheImage(func);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        cTemplateViewElement *listElement = viewList->GetListElement();
 | 
					        cTemplateViewElement *listElement = viewList->GetListElement();
 | 
				
			||||||
        listElement->InitIterator();
 | 
					        listElement->InitIterator();
 | 
				
			||||||
        while(pix = listElement->GetNextPixmap()) {
 | 
					        while(pix = listElement->GetNextPixmap()) {
 | 
				
			||||||
            pix->InitIterator();
 | 
					            CachePixmapImages(pix);
 | 
				
			||||||
            cTemplateFunction *func = NULL;
 | 
					        }
 | 
				
			||||||
            while(func = pix->GetNextFunction()) {
 | 
					        cTemplateViewElement *currentElement = viewList->GetListElementCurrent();
 | 
				
			||||||
                if (func->GetType() == ftDrawImage) {
 | 
					        if (!currentElement) {
 | 
				
			||||||
                    CacheImage(func);
 | 
					            continue;
 | 
				
			||||||
                }
 | 
					        }
 | 
				
			||||||
            }
 | 
					        currentElement->InitIterator();
 | 
				
			||||||
 | 
					        while(pix = currentElement->GetNextPixmap()) {
 | 
				
			||||||
 | 
					            CachePixmapImages(pix);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    //used logos in viewTabs
 | 
					    //used images in viewTabs
 | 
				
			||||||
    view->InitViewTabIterator();
 | 
					    view->InitViewTabIterator();
 | 
				
			||||||
    cTemplateViewTab *viewTab = NULL;
 | 
					    cTemplateViewTab *viewTab = NULL;
 | 
				
			||||||
    while(viewTab = view->GetNextViewTab()) {
 | 
					    while(viewTab = view->GetNextViewTab()) {
 | 
				
			||||||
        viewTab->InitIterator();
 | 
					        CachePixmapImages(viewTab);
 | 
				
			||||||
        cTemplateFunction *func = NULL;
 | 
					 | 
				
			||||||
        while(func = viewTab->GetNextFunction()) {
 | 
					 | 
				
			||||||
            if (func->GetType() == ftDrawImage) {
 | 
					 | 
				
			||||||
                CacheImage(func);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }    
 | 
					    }    
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void cTemplate::CachePixmapImages(cTemplatePixmap *pix) {
 | 
				
			||||||
 | 
					    pix->InitIterator();
 | 
				
			||||||
 | 
					    cTemplateFunction *func = NULL;
 | 
				
			||||||
 | 
					    while(func = pix->GetNextFunction()) {
 | 
				
			||||||
 | 
					        if (func->GetType() == ftDrawImage) {
 | 
				
			||||||
 | 
					            CacheImage(func);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void cTemplate::CacheImage(cTemplateFunction *func) {
 | 
					void cTemplate::CacheImage(cTemplateFunction *func) {
 | 
				
			||||||
    eImageType imgType = (eImageType)func->GetNumericParameter(ptImageType);
 | 
					    eImageType imgType = (eImageType)func->GetNumericParameter(ptImageType);
 | 
				
			||||||
    int width = func->GetNumericParameter(ptWidth);
 | 
					    int width = func->GetNumericParameter(ptWidth);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -32,6 +32,7 @@ enum eViewType {
 | 
				
			|||||||
class cTemplate {
 | 
					class cTemplate {
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    eViewType viewType;
 | 
					    eViewType viewType;
 | 
				
			||||||
 | 
					    void CachePixmapImages(cTemplatePixmap *pix);
 | 
				
			||||||
    void CacheImage(cTemplateFunction *func);
 | 
					    void CacheImage(cTemplateFunction *func);
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
    cGlobals *globals;
 | 
					    cGlobals *globals;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,26 +25,26 @@ public:
 | 
				
			|||||||
// Data structure for service "RegisterPlugin"
 | 
					// Data structure for service "RegisterPlugin"
 | 
				
			||||||
class RegisterPlugin {
 | 
					class RegisterPlugin {
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
	RegisterPlugin(void) {
 | 
					    RegisterPlugin(void) {
 | 
				
			||||||
		name = "";
 | 
					        name = "";
 | 
				
			||||||
	};
 | 
					    };
 | 
				
			||||||
	void SetMenu(int key, string templateName) {
 | 
					    void SetMenu(int key, string templateName) {
 | 
				
			||||||
		menus.insert(pair<int, string>(key, templateName));
 | 
					        menus.insert(pair<int, string>(key, templateName));
 | 
				
			||||||
	}
 | 
					    }
 | 
				
			||||||
// in
 | 
					// in
 | 
				
			||||||
	string name;				 //name of plugin
 | 
					    string name;                 //name of plugin
 | 
				
			||||||
	map< int, string > menus;    //menus as key -> templatename hashmap 
 | 
					    map< int, string > menus;    //menus as key -> templatename hashmap 
 | 
				
			||||||
//out
 | 
					//out
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Data structure for service "GetDisplayMenu"
 | 
					// Data structure for service "GetDisplayMenu"
 | 
				
			||||||
class GetDisplayMenu {
 | 
					class GetDisplayMenu {
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
	GetDisplayMenu(void) {
 | 
					    GetDisplayMenu(void) {
 | 
				
			||||||
		displayMenu = NULL;
 | 
					        displayMenu = NULL;
 | 
				
			||||||
	};
 | 
					    };
 | 
				
			||||||
// in
 | 
					// in
 | 
				
			||||||
//out	
 | 
					//out   
 | 
				
			||||||
	cSDDisplayMenu *displayMenu;
 | 
					    cSDDisplayMenu *displayMenu;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
#endif //__SKINDESIGNERSERVICES_H
 | 
					#endif //__SKINDESIGNERSERVICES_H
 | 
				
			||||||
@@ -4,11 +4,11 @@
 | 
				
			|||||||
* cSkindesignerOsdItem
 | 
					* cSkindesignerOsdItem
 | 
				
			||||||
**********************************************************************/
 | 
					**********************************************************************/
 | 
				
			||||||
cSkindesignerOsdItem::cSkindesignerOsdItem(eOSState State) : cOsdItem(State) {
 | 
					cSkindesignerOsdItem::cSkindesignerOsdItem(eOSState State) : cOsdItem(State) {
 | 
				
			||||||
	sdDisplayMenu = NULL;
 | 
					    sdDisplayMenu = NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cSkindesignerOsdItem::cSkindesignerOsdItem(const char *Text, eOSState State, bool Selectable) : cOsdItem(Text, State, Selectable) {
 | 
					cSkindesignerOsdItem::cSkindesignerOsdItem(const char *Text, eOSState State, bool Selectable) : cOsdItem(Text, State, Selectable) {
 | 
				
			||||||
	sdDisplayMenu = NULL;
 | 
					    sdDisplayMenu = NULL;
 | 
				
			||||||
}  
 | 
					}  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cSkindesignerOsdItem::~cSkindesignerOsdItem() {
 | 
					cSkindesignerOsdItem::~cSkindesignerOsdItem() {
 | 
				
			||||||
@@ -16,33 +16,33 @@ cSkindesignerOsdItem::~cSkindesignerOsdItem() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void cSkindesignerOsdItem::SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable) {
 | 
					void cSkindesignerOsdItem::SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable) {
 | 
				
			||||||
	if (sdDisplayMenu) {
 | 
					    if (sdDisplayMenu) {
 | 
				
			||||||
		if (!sdDisplayMenu->SetItemPlugin(&stringTokens, &intTokens, &loopTokens, Index, Current, Selectable)) {
 | 
					        if (!sdDisplayMenu->SetItemPlugin(&stringTokens, &intTokens, &loopTokens, Index, Current, Selectable)) {
 | 
				
			||||||
			DisplayMenu->SetItem(Text(), Index, Current, Selectable);
 | 
					            DisplayMenu->SetItem(Text(), Index, Current, Selectable);
 | 
				
			||||||
		}
 | 
					        }
 | 
				
			||||||
	} else {
 | 
					    } else {
 | 
				
			||||||
		DisplayMenu->SetItem(Text(), Index, Current, Selectable);
 | 
					        DisplayMenu->SetItem(Text(), Index, Current, Selectable);
 | 
				
			||||||
	}
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void cSkindesignerOsdItem::AddStringToken(string key, string value) {
 | 
					void cSkindesignerOsdItem::AddStringToken(string key, string value) {
 | 
				
			||||||
	stringTokens.insert(pair<string,string>(key, value));
 | 
					    stringTokens.insert(pair<string,string>(key, value));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void cSkindesignerOsdItem::AddIntToken(string key, int value) {
 | 
					void cSkindesignerOsdItem::AddIntToken(string key, int value) {
 | 
				
			||||||
	intTokens.insert(pair<string,int>(key, value));
 | 
					    intTokens.insert(pair<string,int>(key, value));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void cSkindesignerOsdItem::AddLoopToken(string loopName, map<string, string> &tokens) {
 | 
					void cSkindesignerOsdItem::AddLoopToken(string loopName, map<string, string> &tokens) {
 | 
				
			||||||
	map<string, vector<map<string, string> > >::iterator hitLoop = loopTokens.find(loopName);
 | 
					    map<string, vector<map<string, string> > >::iterator hitLoop = loopTokens.find(loopName);
 | 
				
			||||||
	if (hitLoop == loopTokens.end()) {
 | 
					    if (hitLoop == loopTokens.end()) {
 | 
				
			||||||
		vector<map<string, string> > tokenVector;
 | 
					        vector<map<string, string> > tokenVector;
 | 
				
			||||||
		tokenVector.push_back(tokens);
 | 
					        tokenVector.push_back(tokens);
 | 
				
			||||||
		loopTokens.insert(pair<string, vector<map<string, string> > >(loopName, tokenVector));
 | 
					        loopTokens.insert(pair<string, vector<map<string, string> > >(loopName, tokenVector));
 | 
				
			||||||
	} else {
 | 
					    } else {
 | 
				
			||||||
		vector<map<string, string> > *tokenVector = &hitLoop->second;
 | 
					        vector<map<string, string> > *tokenVector = &hitLoop->second;
 | 
				
			||||||
		tokenVector->push_back(tokens);
 | 
					        tokenVector->push_back(tokens);
 | 
				
			||||||
	}
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -50,12 +50,12 @@ void cSkindesignerOsdItem::AddLoopToken(string loopName, map<string, string> &to
 | 
				
			|||||||
* cSkindesignerOsdMenu
 | 
					* cSkindesignerOsdMenu
 | 
				
			||||||
**********************************************************************/
 | 
					**********************************************************************/
 | 
				
			||||||
cSkindesignerOsdMenu::cSkindesignerOsdMenu(const char *Title, int c0, int c1, int c2, int c3, int c4) : cOsdMenu(Title, c0, c1, c2, c3, c4) {
 | 
					cSkindesignerOsdMenu::cSkindesignerOsdMenu(const char *Title, int c0, int c1, int c2, int c3, int c4) : cOsdMenu(Title, c0, c1, c2, c3, c4) {
 | 
				
			||||||
	init = true;
 | 
					    init = true;
 | 
				
			||||||
    displayText = false;
 | 
					    displayText = false;
 | 
				
			||||||
	sdDisplayMenu = NULL;
 | 
					    sdDisplayMenu = NULL;
 | 
				
			||||||
	pluginName = "";
 | 
					    pluginName = "";
 | 
				
			||||||
	SetMenuCategory(mcPlugin);
 | 
					    SetMenuCategory(mcPlugin);
 | 
				
			||||||
	SetSkinDesignerDisplayMenu();
 | 
					    SetSkinDesignerDisplayMenu();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cSkindesignerOsdMenu::~cSkindesignerOsdMenu() {
 | 
					cSkindesignerOsdMenu::~cSkindesignerOsdMenu() {
 | 
				
			||||||
@@ -63,56 +63,56 @@ cSkindesignerOsdMenu::~cSkindesignerOsdMenu() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void cSkindesignerOsdMenu::SetPluginMenu(int menu, eMenuType type) {
 | 
					void cSkindesignerOsdMenu::SetPluginMenu(int menu, eMenuType type) {
 | 
				
			||||||
	if (type == mtList)
 | 
					    if (type == mtList)
 | 
				
			||||||
		displayText = false;
 | 
					        displayText = false;
 | 
				
			||||||
	else if (type == mtText)
 | 
					    else if (type == mtText)
 | 
				
			||||||
		displayText = true;
 | 
					        displayText = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (sdDisplayMenu) {
 | 
					    if (sdDisplayMenu) {
 | 
				
			||||||
		sdDisplayMenu->SetPluginMenu(pluginName, menu, type, init);
 | 
					        sdDisplayMenu->SetPluginMenu(pluginName, menu, type, init);
 | 
				
			||||||
	}
 | 
					    }
 | 
				
			||||||
    init = false;
 | 
					    init = false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool cSkindesignerOsdMenu::SetSkinDesignerDisplayMenu(void) {
 | 
					bool cSkindesignerOsdMenu::SetSkinDesignerDisplayMenu(void) {
 | 
				
			||||||
	static cPlugin *pSkinDesigner = cPluginManager::GetPlugin("skindesigner");
 | 
					    static cPlugin *pSkinDesigner = cPluginManager::GetPlugin("skindesigner");
 | 
				
			||||||
  	if (!pSkinDesigner) {
 | 
					    if (!pSkinDesigner) {
 | 
				
			||||||
    	return false;	
 | 
					        return false;   
 | 
				
			||||||
  	}
 | 
					    }
 | 
				
			||||||
  	GetDisplayMenu call;
 | 
					    GetDisplayMenu call;
 | 
				
			||||||
  	bool ok = pSkinDesigner->Service("GetDisplayMenu", &call);
 | 
					    bool ok = pSkinDesigner->Service("GetDisplayMenu", &call);
 | 
				
			||||||
  	if (ok && call.displayMenu) {
 | 
					    if (ok && call.displayMenu) {
 | 
				
			||||||
  		sdDisplayMenu = call.displayMenu;
 | 
					        sdDisplayMenu = call.displayMenu;
 | 
				
			||||||
  		return true;
 | 
					        return true;
 | 
				
			||||||
  	}
 | 
					    }
 | 
				
			||||||
  	return false;
 | 
					    return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void cSkindesignerOsdMenu::ClearTokens(void) {
 | 
					void cSkindesignerOsdMenu::ClearTokens(void) {
 | 
				
			||||||
	text = "";
 | 
					    text = "";
 | 
				
			||||||
    stringTokens.clear();
 | 
					    stringTokens.clear();
 | 
				
			||||||
    intTokens.clear();
 | 
					    intTokens.clear();
 | 
				
			||||||
    loopTokens.clear();
 | 
					    loopTokens.clear();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void cSkindesignerOsdMenu::AddStringToken(string key, string value) {
 | 
					void cSkindesignerOsdMenu::AddStringToken(string key, string value) {
 | 
				
			||||||
	stringTokens.insert(pair<string,string>(key, value));
 | 
					    stringTokens.insert(pair<string,string>(key, value));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void cSkindesignerOsdMenu::AddIntToken(string key, int value) {
 | 
					void cSkindesignerOsdMenu::AddIntToken(string key, int value) {
 | 
				
			||||||
	intTokens.insert(pair<string,int>(key, value));
 | 
					    intTokens.insert(pair<string,int>(key, value));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void cSkindesignerOsdMenu::AddLoopToken(string loopName, map<string, string> &tokens) {
 | 
					void cSkindesignerOsdMenu::AddLoopToken(string loopName, map<string, string> &tokens) {
 | 
				
			||||||
	map<string, vector<map<string, string> > >::iterator hitLoop = loopTokens.find(loopName);
 | 
					    map<string, vector<map<string, string> > >::iterator hitLoop = loopTokens.find(loopName);
 | 
				
			||||||
	if (hitLoop == loopTokens.end()) {
 | 
					    if (hitLoop == loopTokens.end()) {
 | 
				
			||||||
		vector<map<string, string> > tokenVector;
 | 
					        vector<map<string, string> > tokenVector;
 | 
				
			||||||
		tokenVector.push_back(tokens);
 | 
					        tokenVector.push_back(tokens);
 | 
				
			||||||
		loopTokens.insert(pair<string, vector<map<string, string> > >(loopName, tokenVector));
 | 
					        loopTokens.insert(pair<string, vector<map<string, string> > >(loopName, tokenVector));
 | 
				
			||||||
	} else {
 | 
					    } else {
 | 
				
			||||||
		vector<map<string, string> > *tokenVector = &hitLoop->second;
 | 
					        vector<map<string, string> > *tokenVector = &hitLoop->second;
 | 
				
			||||||
		tokenVector->push_back(tokens);
 | 
					        tokenVector->push_back(tokens);
 | 
				
			||||||
	}
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void cSkindesignerOsdMenu::TextKeyLeft(void) {
 | 
					void cSkindesignerOsdMenu::TextKeyLeft(void) {
 | 
				
			||||||
@@ -140,9 +140,9 @@ void cSkindesignerOsdMenu::TextKeyDown(void) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void cSkindesignerOsdMenu::Display(void) {
 | 
					void cSkindesignerOsdMenu::Display(void) {
 | 
				
			||||||
	if (displayText) {
 | 
					    if (displayText) {
 | 
				
			||||||
		if (sdDisplayMenu) {
 | 
					        if (sdDisplayMenu) {
 | 
				
			||||||
			if (sdDisplayMenu->SetPluginText(&stringTokens, &intTokens, &loopTokens)) {
 | 
					            if (sdDisplayMenu->SetPluginText(&stringTokens, &intTokens, &loopTokens)) {
 | 
				
			||||||
                esyslog("skindesclient: template found");
 | 
					                esyslog("skindesclient: template found");
 | 
				
			||||||
                sdDisplayMenu->Flush();
 | 
					                sdDisplayMenu->Flush();
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
@@ -151,19 +151,19 @@ void cSkindesignerOsdMenu::Display(void) {
 | 
				
			|||||||
                DisplayMenu()->SetText(text.c_str(), false);
 | 
					                DisplayMenu()->SetText(text.c_str(), false);
 | 
				
			||||||
                DisplayMenu()->Flush();
 | 
					                DisplayMenu()->Flush();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
		} else {
 | 
					        } else {
 | 
				
			||||||
            DisplayMenu()->Clear();
 | 
					            DisplayMenu()->Clear();
 | 
				
			||||||
			DisplayMenu()->SetText(text.c_str(), false);
 | 
					            DisplayMenu()->SetText(text.c_str(), false);
 | 
				
			||||||
            DisplayMenu()->Flush();
 | 
					            DisplayMenu()->Flush();
 | 
				
			||||||
		}
 | 
					        }
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
	}
 | 
					    }
 | 
				
			||||||
	if (sdDisplayMenu) {
 | 
					    if (sdDisplayMenu) {
 | 
				
			||||||
		for (cOsdItem *item = First(); item; item = Next(item)) {
 | 
					        for (cOsdItem *item = First(); item; item = Next(item)) {
 | 
				
			||||||
	        cSkindesignerOsdItem *sdItem = dynamic_cast<cSkindesignerOsdItem*>(item);
 | 
					            cSkindesignerOsdItem *sdItem = dynamic_cast<cSkindesignerOsdItem*>(item);
 | 
				
			||||||
	        if (sdItem)
 | 
					            if (sdItem)
 | 
				
			||||||
				sdItem->SetDisplayMenu(sdDisplayMenu);
 | 
					                sdItem->SetDisplayMenu(sdDisplayMenu);
 | 
				
			||||||
		}
 | 
					        }
 | 
				
			||||||
	}
 | 
					    }
 | 
				
			||||||
	cOsdMenu::Display();
 | 
					    cOsdMenu::Display();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,8 +12,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class cSkindesignerOsdItem : public cOsdItem {
 | 
					class cSkindesignerOsdItem : public cOsdItem {
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	cSDDisplayMenu *sdDisplayMenu;
 | 
					    cSDDisplayMenu *sdDisplayMenu;
 | 
				
			||||||
	map < string, string > stringTokens;
 | 
					    map < string, string > stringTokens;
 | 
				
			||||||
    map < string, int > intTokens;
 | 
					    map < string, int > intTokens;
 | 
				
			||||||
    map < string, vector< map< string, string > > > loopTokens;
 | 
					    map < string, vector< map< string, string > > > loopTokens;
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
@@ -22,9 +22,9 @@ public:
 | 
				
			|||||||
    cSkindesignerOsdItem(const char *Text, eOSState State = osUnknown, bool Selectable = true);
 | 
					    cSkindesignerOsdItem(const char *Text, eOSState State = osUnknown, bool Selectable = true);
 | 
				
			||||||
    virtual ~cSkindesignerOsdItem();
 | 
					    virtual ~cSkindesignerOsdItem();
 | 
				
			||||||
    virtual void SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable);
 | 
					    virtual void SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable);
 | 
				
			||||||
	void SetDisplayMenu(cSDDisplayMenu *sdDisplayMenu) { this->sdDisplayMenu = sdDisplayMenu; };
 | 
					    void SetDisplayMenu(cSDDisplayMenu *sdDisplayMenu) { this->sdDisplayMenu = sdDisplayMenu; };
 | 
				
			||||||
    void AddStringToken(string key, string value);
 | 
					    void AddStringToken(string key, string value);
 | 
				
			||||||
	void AddIntToken(string key, int value);
 | 
					    void AddIntToken(string key, int value);
 | 
				
			||||||
    void AddLoopToken(string loopName, map<string, string> &tokens);
 | 
					    void AddLoopToken(string loopName, map<string, string> &tokens);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -34,16 +34,16 @@ private:
 | 
				
			|||||||
    bool init;
 | 
					    bool init;
 | 
				
			||||||
    bool displayText;
 | 
					    bool displayText;
 | 
				
			||||||
    string pluginName;
 | 
					    string pluginName;
 | 
				
			||||||
	cSDDisplayMenu *sdDisplayMenu;
 | 
					    cSDDisplayMenu *sdDisplayMenu;
 | 
				
			||||||
    string text;
 | 
					    string text;
 | 
				
			||||||
    map < string, string > stringTokens;
 | 
					    map < string, string > stringTokens;
 | 
				
			||||||
    map < string, int > intTokens;
 | 
					    map < string, int > intTokens;
 | 
				
			||||||
    map < string, vector< map< string, string > > > loopTokens;
 | 
					    map < string, vector< map< string, string > > > loopTokens;
 | 
				
			||||||
	bool SetSkinDesignerDisplayMenu(void);
 | 
					    bool SetSkinDesignerDisplayMenu(void);
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
    void ClearTokens(void);
 | 
					    void ClearTokens(void);
 | 
				
			||||||
    void SetPluginName(string name) {pluginName = name; };
 | 
					    void SetPluginName(string name) {pluginName = name; };
 | 
				
			||||||
	void SetPluginMenu(int menu, eMenuType type);
 | 
					    void SetPluginMenu(int menu, eMenuType type);
 | 
				
			||||||
    void SetText(string text) { this->text = text; };
 | 
					    void SetText(string text) { this->text = text; };
 | 
				
			||||||
    void AddStringToken(string key, string value);
 | 
					    void AddStringToken(string key, string value);
 | 
				
			||||||
    void AddIntToken(string key, int value);
 | 
					    void AddIntToken(string key, int value);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,17 +7,17 @@
 | 
				
			|||||||
#include "libskindesigner/skindesignerosdbase.h"
 | 
					#include "libskindesigner/skindesignerosdbase.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum eMenus {
 | 
					enum eMenus {
 | 
				
			||||||
	meListMain,
 | 
					    meListMain,
 | 
				
			||||||
    meListSub,
 | 
					    meListSub,
 | 
				
			||||||
	meDetail
 | 
					    meDetail
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class cPlugOsdMenu : public cSkindesignerOsdMenu {
 | 
					class cPlugOsdMenu : public cSkindesignerOsdMenu {
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	void SetMenu(int numItems, bool subfolder = false);
 | 
					    void SetMenu(int numItems, bool subfolder = false);
 | 
				
			||||||
    void SetDetailView(int element);
 | 
					    void SetDetailView(int element);
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
	cPlugOsdMenu(void);
 | 
					    cPlugOsdMenu(void);
 | 
				
			||||||
    virtual ~cPlugOsdMenu();
 | 
					    virtual ~cPlugOsdMenu();
 | 
				
			||||||
    virtual eOSState ProcessKey(eKeys key);
 | 
					    virtual eOSState ProcessKey(eKeys key);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@@ -28,12 +28,12 @@ public:
 | 
				
			|||||||
//***************************************************************************
 | 
					//***************************************************************************
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cPlugOsdMenu::cPlugOsdMenu(void) : cSkindesignerOsdMenu("Skindesigner Client") {
 | 
					cPlugOsdMenu::cPlugOsdMenu(void) : cSkindesignerOsdMenu("Skindesigner Client") {
 | 
				
			||||||
	SetPluginName("skindesclient");
 | 
					    SetPluginName("skindesclient");
 | 
				
			||||||
	SetMenu(10);
 | 
					    SetMenu(10);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cPlugOsdMenu::~cPlugOsdMenu(void) {
 | 
					cPlugOsdMenu::~cPlugOsdMenu(void) {
 | 
				
			||||||
	
 | 
					    
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
eOSState cPlugOsdMenu::ProcessKey(eKeys key) {
 | 
					eOSState cPlugOsdMenu::ProcessKey(eKeys key) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -209,5 +209,5 @@
 | 
				
			|||||||
            </areascroll>
 | 
					            </areascroll>
 | 
				
			||||||
        </currentelement>
 | 
					        </currentelement>
 | 
				
			||||||
    </menuitems>
 | 
					    </menuitems>
 | 
				
			||||||
 | 
					</menuschedules>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</menuschedules>
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user