mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-09-17 12:42:20 +02:00
Cleaned up ReloadableMedia. Work on fixing search paths
This commit is contained in:
@@ -137,8 +137,6 @@ void ReloadableMedia::freeGraphicsMemory()
|
|||||||
}
|
}
|
||||||
void ReloadableMedia::reloadTexture()
|
void ReloadableMedia::reloadTexture()
|
||||||
{
|
{
|
||||||
bool found = false;
|
|
||||||
|
|
||||||
if(loadedComponent_)
|
if(loadedComponent_)
|
||||||
{
|
{
|
||||||
delete loadedComponent_;
|
delete loadedComponent_;
|
||||||
@@ -146,126 +144,142 @@ void ReloadableMedia::reloadTexture()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Item *selectedItem = getSelectedItem();
|
Item *selectedItem = getSelectedItem();
|
||||||
|
if(!selectedItem) return;
|
||||||
|
|
||||||
config_.getProperty("currentCollection", currentCollection_);
|
config_.getProperty("currentCollection", currentCollection_);
|
||||||
|
|
||||||
if (selectedItem != NULL)
|
// build clone list
|
||||||
|
std::vector<std::string> names;
|
||||||
|
|
||||||
|
names.push_back(selectedItem->name);
|
||||||
|
names.push_back(selectedItem->fullTitle);
|
||||||
|
|
||||||
|
if(selectedItem->cloneof.length() > 0)
|
||||||
{
|
{
|
||||||
std::vector<std::string> names;
|
names.push_back(selectedItem->cloneof);
|
||||||
|
}
|
||||||
|
|
||||||
names.push_back(selectedItem->name);
|
if(isVideo_)
|
||||||
names.push_back(selectedItem->fullTitle);
|
{
|
||||||
|
for(unsigned int n = 0; n < names.size() && !loadedComponent_; ++n)
|
||||||
if(selectedItem->cloneof.length() > 0)
|
|
||||||
{
|
{
|
||||||
names.push_back(selectedItem->cloneof);
|
std::string basename = names[n];
|
||||||
}
|
loadedComponent_ = findComponent(collectionName, basename, type_);
|
||||||
|
|
||||||
for(unsigned int n = 0; n < names.size() && !found; ++n)
|
|
||||||
{
|
|
||||||
if(isVideo_)
|
|
||||||
{
|
|
||||||
VideoBuilder videoBuild;
|
|
||||||
std::string videoPath;
|
|
||||||
|
|
||||||
if(systemMode_)
|
|
||||||
{
|
|
||||||
config_.getMediaPropertyAbsolutePath(collectionName, "video", true, videoPath);
|
|
||||||
loadedComponent_ = videoBuild.createVideo(videoPath, "video", scaleX_, scaleY_);
|
|
||||||
|
|
||||||
if(!loadedComponent_)
|
|
||||||
{
|
|
||||||
config_.getMediaPropertyAbsolutePath(selectedItem->collectionInfo->name, "video", false, videoPath);
|
|
||||||
loadedComponent_ = videoBuild.createVideo(videoPath, names[n], scaleX_, scaleY_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!loadedComponent_ && !systemMode_)
|
|
||||||
{
|
|
||||||
config_.getMediaPropertyAbsolutePath(names[n], type_, true, videoPath);
|
|
||||||
loadedComponent_ = videoBuild.createVideo(videoPath, "video", scaleX_, scaleY_);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(loadedComponent_)
|
|
||||||
{
|
|
||||||
loadedComponent_->allocateGraphicsMemory();
|
|
||||||
baseViewInfo.ImageWidth = loadedComponent_->baseViewInfo.ImageWidth;
|
|
||||||
baseViewInfo.ImageHeight = loadedComponent_->baseViewInfo.ImageHeight;
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string imageBasename = names[n];
|
|
||||||
|
|
||||||
std::string typeLC = Utils::toLower(type_);
|
|
||||||
|
|
||||||
if(typeLC == "numberButtons")
|
|
||||||
{
|
|
||||||
imageBasename = selectedItem->numberButtons;
|
|
||||||
}
|
|
||||||
else if(typeLC == "numberPlayers")
|
|
||||||
{
|
|
||||||
imageBasename = selectedItem->numberPlayers;
|
|
||||||
}
|
|
||||||
else if(typeLC == "year")
|
|
||||||
{
|
|
||||||
imageBasename = selectedItem->year;
|
|
||||||
}
|
|
||||||
else if(typeLC == "title")
|
|
||||||
{
|
|
||||||
imageBasename = selectedItem->title;
|
|
||||||
}
|
|
||||||
else if(typeLC == "manufacturer")
|
|
||||||
{
|
|
||||||
imageBasename = selectedItem->manufacturer;
|
|
||||||
}
|
|
||||||
else if(typeLC == "genre")
|
|
||||||
{
|
|
||||||
imageBasename = selectedItem->genre;
|
|
||||||
}
|
|
||||||
|
|
||||||
Utils::replaceSlashesWithUnderscores(imageBasename);
|
|
||||||
|
|
||||||
if(!loadedComponent_)
|
if(!loadedComponent_)
|
||||||
{
|
{
|
||||||
std::string imagePath;
|
loadedComponent_ = findComponent(selectedItem->collectionInfo->name, basename, type_);
|
||||||
|
|
||||||
ImageBuilder imageBuild;
|
|
||||||
|
|
||||||
if(systemMode_)
|
|
||||||
{
|
|
||||||
config_.getMediaPropertyAbsolutePath(collectionName, type_, true, imagePath);
|
|
||||||
loadedComponent_ = imageBuild.CreateImage(imagePath, type_, scaleX_, scaleY_);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
config_.getMediaPropertyAbsolutePath(selectedItem->collectionInfo->name, type_, false, imagePath);
|
|
||||||
loadedComponent_ = imageBuild.CreateImage(imagePath, imageBasename, scaleX_, scaleY_);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!loadedComponent_ && !systemMode_)
|
|
||||||
{
|
|
||||||
config_.getMediaPropertyAbsolutePath(imageBasename, type_, true, imagePath);
|
|
||||||
loadedComponent_ = imageBuild.CreateImage(imagePath, type_, scaleX_, scaleY_);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (loadedComponent_ != NULL)
|
|
||||||
{
|
|
||||||
loadedComponent_->allocateGraphicsMemory();
|
|
||||||
baseViewInfo.ImageWidth = loadedComponent_->baseViewInfo.ImageWidth;
|
|
||||||
baseViewInfo.ImageHeight = loadedComponent_->baseViewInfo.ImageHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!loadedComponent_ && textFallback_)
|
if(loadedComponent_)
|
||||||
{
|
{
|
||||||
loadedComponent_ = new Text(imageBasename, FfntInst_, scaleX_, scaleY_);
|
loadedComponent_->allocateGraphicsMemory();
|
||||||
baseViewInfo.ImageWidth = loadedComponent_->baseViewInfo.ImageWidth;
|
baseViewInfo.ImageWidth = loadedComponent_->baseViewInfo.ImageWidth;
|
||||||
baseViewInfo.ImageHeight = loadedComponent_->baseViewInfo.ImageHeight;
|
baseViewInfo.ImageHeight = loadedComponent_->baseViewInfo.ImageHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check for images if video could not be found (and was specified)
|
||||||
|
for(unsigned int n = 0; n < names.size() && !loadedComponent_; ++n)
|
||||||
|
{
|
||||||
|
std::string imageBasename = names[n];
|
||||||
|
|
||||||
|
std::string typeLC = Utils::toLower(type_);
|
||||||
|
|
||||||
|
if(typeLC == "numberButtons")
|
||||||
|
{
|
||||||
|
imageBasename = selectedItem->numberButtons;
|
||||||
|
}
|
||||||
|
else if(typeLC == "numberPlayers")
|
||||||
|
{
|
||||||
|
imageBasename = selectedItem->numberPlayers;
|
||||||
|
}
|
||||||
|
else if(typeLC == "year")
|
||||||
|
{
|
||||||
|
imageBasename = selectedItem->year;
|
||||||
|
}
|
||||||
|
else if(typeLC == "title")
|
||||||
|
{
|
||||||
|
imageBasename = selectedItem->title;
|
||||||
|
}
|
||||||
|
else if(typeLC == "manufacturer")
|
||||||
|
{
|
||||||
|
imageBasename = selectedItem->manufacturer;
|
||||||
|
}
|
||||||
|
else if(typeLC == "genre")
|
||||||
|
{
|
||||||
|
imageBasename = selectedItem->genre;
|
||||||
|
}
|
||||||
|
|
||||||
|
Utils::replaceSlashesWithUnderscores(imageBasename);
|
||||||
|
|
||||||
|
std::string imagePath;
|
||||||
|
|
||||||
|
loadedComponent_ = findComponent(collectionName, imageBasename, type_);
|
||||||
|
|
||||||
|
if(!loadedComponent_)
|
||||||
|
{
|
||||||
|
loadedComponent_ = findComponent(selectedItem->collectionInfo->name, imageBasename, type_);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loadedComponent_ != NULL)
|
||||||
|
{
|
||||||
|
loadedComponent_->allocateGraphicsMemory();
|
||||||
|
baseViewInfo.ImageWidth = loadedComponent_->baseViewInfo.ImageWidth;
|
||||||
|
baseViewInfo.ImageHeight = loadedComponent_->baseViewInfo.ImageHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if image and artwork was not specified, fall back to displaying text
|
||||||
|
if(!loadedComponent_ && textFallback_)
|
||||||
|
{
|
||||||
|
loadedComponent_ = new Text(selectedItem->fullTitle, FfntInst_, scaleX_, scaleY_);
|
||||||
|
baseViewInfo.ImageWidth = loadedComponent_->baseViewInfo.ImageWidth;
|
||||||
|
baseViewInfo.ImageHeight = loadedComponent_->baseViewInfo.ImageHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Component *ReloadableMedia::findComponent(std::string collection, std::string basename, std::string type)
|
||||||
|
{
|
||||||
|
std::string imagePath;
|
||||||
|
Component *component = NULL;
|
||||||
|
VideoBuilder videoBuild;
|
||||||
|
ImageBuilder imageBuild;
|
||||||
|
// check the current collection
|
||||||
|
|
||||||
|
if(systemMode_)
|
||||||
|
{
|
||||||
|
// check the system folder
|
||||||
|
config_.getMediaPropertyAbsolutePath(collection, type, true, imagePath);
|
||||||
|
|
||||||
|
if(type == "video")
|
||||||
|
{
|
||||||
|
component = videoBuild.createVideo(imagePath, type, scaleX_, scaleY_);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
component = imageBuild.CreateImage(imagePath, type, scaleX_, scaleY_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// check the list folders
|
||||||
|
config_.getMediaPropertyAbsolutePath(collection, type, false, imagePath);
|
||||||
|
|
||||||
|
if(type == "video")
|
||||||
|
{
|
||||||
|
component = videoBuild.createVideo(imagePath, basename, scaleX_, scaleY_);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
component = imageBuild.CreateImage(imagePath, basename, scaleX_, scaleY_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return component;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReloadableMedia::draw()
|
void ReloadableMedia::draw()
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ public:
|
|||||||
void allocateGraphicsMemory();
|
void allocateGraphicsMemory();
|
||||||
void launchEnter();
|
void launchEnter();
|
||||||
void launchExit();
|
void launchExit();
|
||||||
|
Component *findComponent(std::string collection, std::string basename, std::string type);
|
||||||
|
|
||||||
void enableTextFallback_(bool value);
|
void enableTextFallback_(bool value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user