delete duplicate code, enable search in find/replace dialog in selected in component mode
This commit is contained in:
parent
7b28489554
commit
adc6adf50e
|
|
@ -688,30 +688,27 @@ void operator()( Face& face ) const {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class FaceFindShader
|
class FaceSelectByShader
|
||||||
{
|
{
|
||||||
const char* m_find;
|
const char* m_name;
|
||||||
public:
|
public:
|
||||||
FaceFindShader( const char* find ) : m_find( find ){
|
FaceSelectByShader( const char* name )
|
||||||
|
: m_name( name ){
|
||||||
}
|
}
|
||||||
void operator()( FaceInstance& faceinst ) const {
|
void operator()( FaceInstance& face ) const {
|
||||||
if ( shader_equal( faceinst.getFace().GetShader(), m_find ) ) {
|
if ( shader_equal( face.getFace().GetShader(), m_name ) ) {
|
||||||
faceinst.setSelected( SelectionSystem::eFace, true );
|
face.setSelected( SelectionSystem::eFace, true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void Scene_BrushFacesSelectByShader( scene::Graph& graph, const char* name ){
|
void Scene_BrushFacesSelectByShader( scene::Graph& graph, const char* name ){
|
||||||
Scene_ForEachBrush_ForEachFaceInstance( graph, FaceFindShader( name ) );
|
Scene_ForEachBrush_ForEachFaceInstance( graph, FaceSelectByShader( name ) );
|
||||||
}
|
|
||||||
|
|
||||||
bool DoingSearch( const char *repl ){
|
|
||||||
return ( repl == NULL || ( strcmp( "textures/", repl ) == 0 ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene_BrushFindReplaceShader( scene::Graph& graph, const char* find, const char* replace ){
|
void Scene_BrushFindReplaceShader( scene::Graph& graph, const char* find, const char* replace ){
|
||||||
if ( DoingSearch( replace ) ) {
|
if ( !replace ) {
|
||||||
Scene_ForEachBrush_ForEachFaceInstance( graph, FaceFindShader( find ) );
|
Scene_ForEachBrush_ForEachFaceInstance( graph, FaceSelectByShader( find ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -720,9 +717,9 @@ void Scene_BrushFindReplaceShader( scene::Graph& graph, const char* find, const
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene_BrushFindReplaceShader_Selected( scene::Graph& graph, const char* find, const char* replace ){
|
void Scene_BrushFindReplaceShader_Selected( scene::Graph& graph, const char* find, const char* replace ){
|
||||||
if ( DoingSearch( replace ) ) {
|
if ( !replace ) {
|
||||||
Scene_ForEachSelectedBrush_ForEachFaceInstance( graph,
|
Scene_ForEachSelectedBrush_ForEachFaceInstance( graph,
|
||||||
FaceFindShader( find ) );
|
FaceSelectByShader( find ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -734,8 +731,9 @@ void Scene_BrushFindReplaceShader_Selected( scene::Graph& graph, const char* fin
|
||||||
// TODO: find for components
|
// TODO: find for components
|
||||||
// d1223m: dont even know what they are...
|
// d1223m: dont even know what they are...
|
||||||
void Scene_BrushFindReplaceShader_Component_Selected( scene::Graph& graph, const char* find, const char* replace ){
|
void Scene_BrushFindReplaceShader_Component_Selected( scene::Graph& graph, const char* find, const char* replace ){
|
||||||
if ( DoingSearch( replace ) ) {
|
if ( !replace ) {
|
||||||
|
Scene_ForEachSelectedBrush_ForEachFaceInstance( graph,
|
||||||
|
FaceSelectByShader( find ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -897,21 +895,6 @@ void Scene_BrushSelectByShader( scene::Graph& graph, const char* name ){
|
||||||
graph.traverse( BrushSelectByShaderWalker( name ) );
|
graph.traverse( BrushSelectByShaderWalker( name ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
class FaceSelectByShader
|
|
||||||
{
|
|
||||||
const char* m_name;
|
|
||||||
public:
|
|
||||||
FaceSelectByShader( const char* name )
|
|
||||||
: m_name( name ){
|
|
||||||
}
|
|
||||||
void operator()( FaceInstance& face ) const {
|
|
||||||
printf( "checking %s = %s\n", face.getFace().GetShader(), m_name );
|
|
||||||
if ( shader_equal( face.getFace().GetShader(), m_name ) ) {
|
|
||||||
face.setSelected( SelectionSystem::eFace, true );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void Scene_BrushSelectByShader_Component( scene::Graph& graph, const char* name ){
|
void Scene_BrushSelectByShader_Component( scene::Graph& graph, const char* name ){
|
||||||
Scene_ForEachSelectedBrush_ForEachFaceInstance( graph, FaceSelectByShader( name ) );
|
Scene_ForEachSelectedBrush_ForEachFaceInstance( graph, FaceSelectByShader( name ) );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -491,13 +491,8 @@ void operator()( Patch& patch ) const {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace{
|
|
||||||
bool DoingSearch( const char *repl ){
|
|
||||||
return ( repl == NULL || ( strcmp( "textures/", repl ) == 0 ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void Scene_PatchFindReplaceShader( scene::Graph& graph, const char* find, const char* replace ){
|
void Scene_PatchFindReplaceShader( scene::Graph& graph, const char* find, const char* replace ){
|
||||||
if( DoingSearch( replace ) ){
|
if( !replace ){
|
||||||
Scene_forEachVisiblePatchInstance( PatchSelectByShader( find ) );
|
Scene_forEachVisiblePatchInstance( PatchSelectByShader( find ) );
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
@ -506,7 +501,7 @@ void Scene_PatchFindReplaceShader( scene::Graph& graph, const char* find, const
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene_PatchFindReplaceShader_Selected( scene::Graph& graph, const char* find, const char* replace ){
|
void Scene_PatchFindReplaceShader_Selected( scene::Graph& graph, const char* find, const char* replace ){
|
||||||
if( DoingSearch( replace ) ){
|
if( !replace ){
|
||||||
//do nothing, because alternative is replacing to notex
|
//do nothing, because alternative is replacing to notex
|
||||||
//perhaps deselect ones with not matching shaders here?
|
//perhaps deselect ones with not matching shaders here?
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -705,6 +705,9 @@ void FindReplaceTextures( const char* pFind, const char* pReplace, bool bSelecte
|
||||||
command << "textureFindReplace -find " << pFind << " -replace " << pReplace;
|
command << "textureFindReplace -find " << pFind << " -replace " << pReplace;
|
||||||
UndoableCommand undo( command.c_str() );
|
UndoableCommand undo( command.c_str() );
|
||||||
|
|
||||||
|
if( shader_equal( pReplace, "textures/" ) )
|
||||||
|
pReplace = 0; //do search
|
||||||
|
|
||||||
if ( bSelected ) {
|
if ( bSelected ) {
|
||||||
if ( GlobalSelectionSystem().Mode() != SelectionSystem::eComponent ) {
|
if ( GlobalSelectionSystem().Mode() != SelectionSystem::eComponent ) {
|
||||||
Scene_BrushFindReplaceShader_Selected( GlobalSceneGraph(), pFind, pReplace );
|
Scene_BrushFindReplaceShader_Selected( GlobalSceneGraph(), pFind, pReplace );
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user