Skip to content

Commit

Permalink
#5565: Add stub saveMaterial method
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Mar 28, 2021
1 parent e36e9b7 commit 2481e99
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
4 changes: 4 additions & 0 deletions include/ishaders.h
Expand Up @@ -595,6 +595,10 @@ class MaterialManager

virtual void removeMaterial(const std::string& name) = 0;

// Saves the named material to the file location as specified in its shaderfile info.
// If the path is not writable or the material is not suitable for saving, this will throw an exception
virtual void saveMaterial(const std::string& name) = 0;

// Creates a named, internal material for debug/testing etc.
// Used by shaders without corresponding material declaration, like entity wireframe shaders
virtual MaterialPtr createDefaultMaterial(const std::string& name) = 0;
Expand Down
15 changes: 14 additions & 1 deletion radiant/ui/materials/editor/MaterialEditor.cpp
Expand Up @@ -1121,7 +1121,20 @@ bool MaterialEditor::saveCurrentMaterial()
_material->setShaderFileName(os::standardPath(result));
}

// TODO: Let the shader module write the material file
try
{
// Write to the specified .mtr file
GlobalMaterialManager().saveMaterial(_material->getName());
}
catch (const std::runtime_error& ex)
{
rError() << "Could not save file: " << ex.what() << std::endl;
wxutil::Messagebox::ShowError(ex.what(), this);

return false; // failure means to abort the process
}

updateMaterialTreeItem();

return true;
}
Expand Down
7 changes: 7 additions & 0 deletions radiantcore/shaders/Doom3ShaderSystem.cpp
Expand Up @@ -434,6 +434,13 @@ MaterialPtr Doom3ShaderSystem::copyMaterial(const std::string& nameOfOriginal, c
return material;
}

void Doom3ShaderSystem::saveMaterial(const std::string& name)
{
ensureDefsLoaded();


}

ITableDefinition::Ptr Doom3ShaderSystem::getTable(const std::string& name)
{
ensureDefsLoaded();
Expand Down
1 change: 1 addition & 0 deletions radiantcore/shaders/Doom3ShaderSystem.h
Expand Up @@ -123,6 +123,7 @@ class Doom3ShaderSystem :
MaterialPtr copyMaterial(const std::string& nameOfOriginal, const std::string& nameOfCopy) override;
bool renameMaterial(const std::string& oldName, const std::string& newName) override;
void removeMaterial(const std::string& name) override;
void saveMaterial(const std::string& name) override;

// Look up a table def, return NULL if not found
ITableDefinition::Ptr getTable(const std::string& name);
Expand Down

0 comments on commit 2481e99

Please sign in to comment.