Commit 6cef69c3 authored by Supernature2k's avatar Supernature2k Committed by OyyoDams

Resolve "default system theme"

parent 3b444cdc
......@@ -49,11 +49,11 @@ std::string removeParenthesis(const std::string& str)
FileData::FileData(FileType type, const fs::path& path, SystemData* system)
: metadata(getCleanName()), // TODO: Move clean name into metadata
mType(type),
: mType(type),
mPath(path),
mSystem(system),
mParent(NULL)
mParent(NULL),
metadata(getCleanName()) // TODO: Move clean name into metadata
{
}
......@@ -70,9 +70,8 @@ std::string FileData::getCleanName() const
std::string stem = mPath.stem().generic_string();
if(mSystem && (mSystem->hasPlatformId(PlatformIds::ARCADE) || mSystem->hasPlatformId(PlatformIds::NEOGEO)))
stem = PlatformIds::getCleanMameName(stem.c_str());
return stem;
return removeParenthesis(stem);
return stem;
}
const std::string& FileData::getThumbnailPath() const
......
......@@ -79,6 +79,7 @@ const MetadataFieldDescriptor* MetadataDescriptor::GetMetadataFieldDescriptors(M
count = sizeof(_FolderMetadataDescriptors) / sizeof(MetadataFieldDescriptor);
return &_FolderMetadataDescriptors[0];
}
case ObjectType::None:
default: break;
}
count = 0;
......@@ -576,6 +577,16 @@ void MetadataDescriptor::FreeAll()
FreePString(*((std::string**)source));
break;
}
case MetadataFieldDescriptor::DataType::Rating:
case MetadataFieldDescriptor::DataType::String:
case MetadataFieldDescriptor::DataType::Int:
case MetadataFieldDescriptor::DataType::Bool:
case MetadataFieldDescriptor::DataType::Float:
case MetadataFieldDescriptor::DataType::Text:
case MetadataFieldDescriptor::DataType::Path:
case MetadataFieldDescriptor::DataType::Date:
case MetadataFieldDescriptor::DataType::Range:
case MetadataFieldDescriptor::DataType::Crc32:
default: break;
}
......
......@@ -153,6 +153,8 @@ std::string escapePath(const boost::filesystem::path &path)
void SystemData::launchGame(Window* window, FileData* game, const std::string& netplay, const std::string& core, const std::string& ip, const std::string& port)
{
(void)core;
LOG(LogInfo) << "Attempting to launch game...";
AudioManager::getInstance()->deinit();
......@@ -614,12 +616,22 @@ std::string SystemData::getThemePath() const
localThemePath = ThemeData::getThemeFromCurrentSet(mThemeFolder);
if (fs::exists(localThemePath))
return localThemePath.generic_string();
return localThemePath.generic_string();
// not system theme, try default system theme in theme set
localThemePath = localThemePath.parent_path().parent_path() / "theme.xml";
return localThemePath.generic_string();
if (fs::exists(localThemePath))
return localThemePath.generic_string();
//none of the above, try default
localThemePath = localThemePath.parent_path() / "default/theme.xml";
if (fs::exists(localThemePath))
return localThemePath.generic_string();
// No luck...
return "";
}
unsigned int SystemData::getGameCount() const
......@@ -648,14 +660,15 @@ void SystemData::loadTheme()
try
{
//std::cout << "creating theme for: " << getName() << " / " << getFullName() << std::endl;
mTheme->loadFile(getThemeFolder(), path);
mHasFavorites = mTheme->getHasFavoritesInTheme();
}
catch (ThemeException &e)
{
LOG(LogError) << e.what();
mTheme = std::make_shared<ThemeData>(); // reset to empty
LOG(LogError) << e.what();
mThemeFolder = "default";
mTheme->loadFile(getThemeFolder(), path);
mHasFavorites = mTheme->getHasFavoritesInTheme();
}
}
......
......@@ -246,6 +246,14 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
}
break;
case MetadataFieldDescriptor::DataType::Text:
case MetadataFieldDescriptor::DataType::String:
case MetadataFieldDescriptor::DataType::PString:
case MetadataFieldDescriptor::DataType::Int:
case MetadataFieldDescriptor::DataType::Float:
case MetadataFieldDescriptor::DataType::Path:
case MetadataFieldDescriptor::DataType::PPath:
case MetadataFieldDescriptor::DataType::Range:
case MetadataFieldDescriptor::DataType::Crc32:
default:
{
// MD_STRING
......
......@@ -61,6 +61,21 @@ void SystemView::addSystem(SystemData * it){
logo->setMaxSize(mCarousel.logoSize * mCarousel.logoScale);
logo->applyTheme((it)->getTheme(), "system", "logo", ThemeFlags::PATH);
e.data.logo = std::shared_ptr<GuiComponent>(logo);
if ((it)->getThemeFolder() == "default")
{
TextComponent* text = new TextComponent(mWindow,
(it)->getName(),
Font::get(FONT_SIZE_MEDIUM),
0x1A1A1AFF,
ALIGN_CENTER);
text->setSize(mCarousel.logoSize * mCarousel.logoScale);
e.data.logotext = std::shared_ptr<GuiComponent>(text);
if (mCarousel.type == VERTICAL || mCarousel.type == VERTICAL_WHEEL)
text->setHorizontalAlignment(mCarousel.logoAlignment);
else
text->setVerticalAlignment(mCarousel.logoAlignment);
}
}else{
// no logo in theme; use text
TextComponent* text = new TextComponent(mWindow,
......@@ -96,6 +111,29 @@ void SystemView::addSystem(SystemData * it){
Eigen::Vector2f denormalized = mCarousel.logoSize.cwiseProduct(e.data.logo->getOrigin());
e.data.logo->setPosition(denormalized.x(), denormalized.y(), 0.0);
if (e.data.logotext)
{
if (mCarousel.type == VERTICAL || mCarousel.type == VERTICAL_WHEEL)
{
if (mCarousel.logoAlignment == ALIGN_LEFT)
e.data.logotext->setOrigin(0, 0.5);
else if (mCarousel.logoAlignment == ALIGN_RIGHT)
e.data.logotext->setOrigin(1.0, 0.5);
else
e.data.logotext->setOrigin(0.5, 0.5);
} else {
if (mCarousel.logoAlignment == ALIGN_TOP)
e.data.logotext->setOrigin(0.5, 0);
else if (mCarousel.logoAlignment == ALIGN_BOTTOM)
e.data.logotext->setOrigin(0.5, 1);
else
e.data.logotext->setOrigin(0.5, 0.5);
}
Eigen::Vector2f denormalized = mCarousel.logoSize.cwiseProduct(e.data.logotext->getOrigin());
e.data.logotext->setPosition(denormalized.x(), denormalized.y(), 0.0);
}
e.data.backgroundExtras = std::shared_ptr<ThemeExtras>(new ThemeExtras(mWindow));
e.data.backgroundExtras->setExtras(ThemeData::makeExtras((it)->getTheme(), "system", mWindow));
......@@ -629,6 +667,18 @@ void SystemView::renderCarousel(const Eigen::Affine3f& trans)
comp->setScale(scale);
comp->setOpacity(opacity);
comp->render(logoTrans);
if (mEntries.at(index).data.logotext)
{
const std::shared_ptr<GuiComponent> &comp2 = mEntries.at(index).data.logotext;
if (mCarousel.type == VERTICAL_WHEEL) {
comp2->setRotationDegrees(mCarousel.logoRotation * distance);
comp2->setRotationOrigin(mCarousel.logoRotationOrigin);
}
comp2->setScale(scale);
comp2->setOpacity(opacity);
comp2->render(logoTrans);
}
}
Renderer::popClipRect();
}
......
......@@ -20,6 +20,7 @@ enum CarouselType : unsigned int
struct SystemViewData
{
std::shared_ptr<GuiComponent> logo;
std::shared_ptr<GuiComponent> logotext;
std::shared_ptr<ThemeExtras> backgroundExtras;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment