Skip to content

Commit

Permalink
#5565: Export guisurf variants
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Mar 25, 2021
1 parent 00f6d07 commit 04b6639
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
23 changes: 23 additions & 0 deletions radiantcore/shaders/MaterialSourceGenerator.cpp
Expand Up @@ -49,6 +49,29 @@ std::ostream& operator<<(std::ostream& stream, ShaderTemplate& shaderTemplate)
stream << "\t" << getStringForCullType(shaderTemplate.getCullType()) << "\n";
}

// GuiSurf
if (shaderTemplate.getSurfaceFlags() & Material::SURF_GUISURF)
{
stream << "\tguisurf ";

if (shaderTemplate.getSurfaceFlags() & Material::SURF_ENTITYGUI)
{
stream << "entity\n";
}
else if (shaderTemplate.getSurfaceFlags() & Material::SURF_ENTITYGUI2)
{
stream << "entity2\n";
}
else if (shaderTemplate.getSurfaceFlags() & Material::SURF_ENTITYGUI3)
{
stream << "entity3\n";
}
else
{
stream << shaderTemplate.getGuiSurfArgument() << "\n";
}
}

for (const auto& layer : shaderTemplate.getLayers())
{
stream << "\t{\n";
Expand Down
39 changes: 39 additions & 0 deletions test/MaterialExport.cpp
Expand Up @@ -135,4 +135,43 @@ TEST_F(MaterialExportTest, CullType)
expectDefinitionDoesNotContain(material, "backsided");
}

TEST_F(MaterialExportTest, GuiSurf)
{
auto material = GlobalMaterialManager().getMaterial("textures/exporttest/guisurf1");
expectDefinitionContains(material, "guiSurf\tguis/lvlmaps/genericmap.gui");

// Mark the definition as modified by setting the description
material->setDescription("-");
material->setDescription("");

expectDefinitionContains(material, "guisurf guis/lvlmaps/genericmap.gui");

material = GlobalMaterialManager().getMaterial("textures/exporttest/guisurf2");
expectDefinitionContains(material, "guiSurf\tentity");

// Mark the definition as modified by setting the description
material->setDescription("-");
material->setDescription("");

expectDefinitionContains(material, "guisurf entity");

material = GlobalMaterialManager().getMaterial("textures/exporttest/guisurf3");
expectDefinitionContains(material, "guiSurf\tentity2");

// Mark the definition as modified by setting the description
material->setDescription("-");
material->setDescription("");

expectDefinitionContains(material, "guisurf entity2");

material = GlobalMaterialManager().getMaterial("textures/exporttest/guisurf4");
expectDefinitionContains(material, "guiSurf\tentity3");

// Mark the definition as modified by setting the description
material->setDescription("-");
material->setDescription("");

expectDefinitionContains(material, "guisurf entity3");
}

}
20 changes: 20 additions & 0 deletions test/resources/tdm/materials/exporttest.mtr
@@ -1,3 +1,23 @@
textures/exporttest/empty
{
}

textures/exporttest/guisurf1
{
guiSurf guis/lvlmaps/genericmap.gui
}

textures/exporttest/guisurf2
{
guiSurf entity
}

textures/exporttest/guisurf3
{
guiSurf entity2
}

textures/exporttest/guisurf4
{
guiSurf entity3
}

0 comments on commit 04b6639

Please sign in to comment.