}
}
-template<typename Type>
-class InstanceEvaluateTransform
-{
-public:
-inline void operator()( scene::Instance& instance ) const {
- InstanceTypeCast<Type>::cast( instance )->evaluateTransform();
-}
-};
-
template<typename Type>
class InstanceSetEvaluateTransform
{
public:
static void apply( InstanceSet& instances ){
- InstanceSet_forEach( instances, InstanceEvaluateTransform<Type>() );
+ InstanceSet_forEach(instances, [&](scene::Instance &instance) {
+ InstanceTypeCast<Type>::cast(instance)->evaluateTransform();
+ });
}
typedef ReferenceCaller<InstanceSet, &InstanceSetEvaluateTransform<Type>::apply> Caller;
};
}
}
-class AABBExtendByPoint
-{
-AABB& m_aabb;
-public:
-AABBExtendByPoint( AABB& aabb ) : m_aabb( aabb ){
-}
-void operator()( const Vector3& point ) const {
- aabb_extend_by_point_safe( m_aabb, point );
-}
-};
-
inline void aabb_extend_by_aabb( AABB& aabb, const AABB& other ){
AABBExtend< IntegralConstant<0> >::apply( aabb, other );
AABBExtend< IntegralConstant<1> >::apply( aabb, other );
}
}
-class ControlPointTransform
-{
-const Matrix4& m_matrix;
-public:
-ControlPointTransform( const Matrix4& matrix ) : m_matrix( matrix ){
-}
-void operator()( Vector3& point ) const {
- matrix4_transform_point( m_matrix, point );
-}
-};
-
-class ControlPointSnap
-{
-float m_snap;
-public:
-ControlPointSnap( float snap ) : m_snap( snap ){
-}
-void operator()( Vector3& point ) const {
- vector3_snap( point, m_snap );
-}
-};
-
-class ControlPointAdd
-{
-RenderablePointVector& m_points;
-public:
-ControlPointAdd( RenderablePointVector& points ) : m_points( points ){
-}
-void operator()( const Vector3& point ) const {
- m_points.push_back( PointVertex( vertex3f_for_vector3( point ), colour_vertex ) );
-}
-};
-
-class ControlPointAddSelected
-{
-RenderablePointVector& m_points;
-public:
-ControlPointAddSelected( RenderablePointVector& points ) : m_points( points ){
-}
-void operator()( const Vector3& point ) const {
- m_points.push_back( PointVertex( vertex3f_for_vector3( point ), colour_selected ) );
-}
-};
-
class CurveEditType
{
public:
}
void transform( const Matrix4& matrix ){
- forEachSelected( ControlPointTransform( matrix ) );
+ forEachSelected([&](Vector3 &point) {
+ matrix4_transform_point(matrix, point);
+ });
}
void snapto( float snap ){
- forEachSelected( ControlPointSnap( snap ) );
+ forEachSelected([&](Vector3 &point) {
+ vector3_snap(point, snap);
+ });
}
void updateSelected() const {
m_selectedRender.clear();
- forEachSelected( ControlPointAddSelected( m_selectedRender ) );
+ forEachSelected([&](const Vector3 &point) {
+ m_selectedRender.push_back(PointVertex(vertex3f_for_vector3(point), colour_selected));
+ });
}
void renderComponents( Renderer& renderer, const VolumeTest& volume, const Matrix4& localToWorld ) const {
m_controlsRender.clear();
m_controlsRender.reserve( m_controlPoints.size() );
- forEach( ControlPointAdd( m_controlsRender ) );
+ forEach([&](const Vector3 &point) {
+ m_controlsRender.push_back(PointVertex(vertex3f_for_vector3(point), colour_vertex));
+ });
m_selectedRender.reserve( m_controlPoints.size() );
}
typedef MemberCaller<Doom3Group, &Doom3Group::transformChanged> TransformChangedCaller;
};
-class ControlPointAddBounds
-{
-AABB& m_bounds;
-public:
-ControlPointAddBounds( AABB& bounds ) : m_bounds( bounds ){
-}
-void operator()( const Vector3& point ) const {
- aabb_extend_by_point_safe( m_bounds, point );
-}
-};
-
class Doom3GroupInstance :
public TargetableInstance,
public TransformModifier,
const AABB& getSelectedComponentsBounds() const {
m_aabb_component = AABB();
- m_curveNURBS.forEachSelected( ControlPointAddBounds( m_aabb_component ) );
- m_curveCatmullRom.forEachSelected( ControlPointAddBounds( m_aabb_component ) );
+ m_curveNURBS.forEachSelected([&](const Vector3 &point) {
+ aabb_extend_by_point_safe(m_aabb_component, point);
+ });
+ m_curveCatmullRom.forEachSelected([&](const Vector3 &point) {
+ aabb_extend_by_point_safe(m_aabb_component, point);
+ });
return m_aabb_component;
}
virtual void unrealiseShader() = 0;
};
-class FaceShaderObserverRealise
-{
-public:
-void operator()( FaceShaderObserver& observer ) const {
- observer.realiseShader();
-}
-};
-
-class FaceShaderObserverUnrealise
-{
-public:
-void operator()( FaceShaderObserver& observer ) const {
- observer.unrealiseShader();
-}
-};
-
typedef ReferencePair<FaceShaderObserver> FaceShaderObserverPair;
void realise(){
ASSERT_MESSAGE( !m_realised, "FaceTexdef::realise: already realised" );
m_realised = true;
- m_observers.forEach( FaceShaderObserverRealise() );
+ m_observers.forEach([](FaceShaderObserver &observer) {
+ observer.realiseShader();
+ });
}
void unrealise(){
ASSERT_MESSAGE( m_realised, "FaceTexdef::unrealise: already unrealised" );
- m_observers.forEach( FaceShaderObserverUnrealise() );
+ m_observers.forEach([](FaceShaderObserver &observer) {
+ observer.unrealiseShader();
+ });
m_realised = false;
}
}
void iterate_selected( AABB& aabb ) const {
- SelectedComponents_foreach( AABBExtendByPoint( aabb ) );
+ SelectedComponents_foreach([&](const Vector3 &point) {
+ aabb_extend_by_point_safe(aabb, point);
+ });
}
-class RenderablePointVectorPushBack
-{
-RenderablePointVector& m_points;
-public:
-RenderablePointVectorPushBack( RenderablePointVector& points ) : m_points( points ){
-}
-void operator()( const Vector3& point ) const {
- const Colour4b colour_selected( 0, 0, 255, 255 );
- m_points.push_back( pointvertex_for_windingpoint( point, colour_selected ) );
-}
-};
-
void iterate_selected( RenderablePointVector& points ) const {
- SelectedComponents_foreach( RenderablePointVectorPushBack( points ) );
+ SelectedComponents_foreach([&](const Vector3 &point) {
+ const Colour4b colour_selected(0, 0, 255, 255);
+ points.push_back(pointvertex_for_windingpoint(point, colour_selected));
+ });
}
bool intersectVolume( const VolumeTest& volume, const Matrix4& localToWorld ) const {
}
-class FaceSetTexdef
-{
-const TextureProjection& m_projection;
-public:
-FaceSetTexdef( const TextureProjection& projection ) : m_projection( projection ){
-}
-void operator()( Face& face ) const {
- face.SetTexdef( m_projection );
-}
-};
-
void Scene_BrushSetTexdef_Selected( scene::Graph& graph, const TextureProjection& projection ){
- Scene_ForEachSelectedBrush_ForEachFace( graph, FaceSetTexdef( projection ) );
+ Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
+ face.SetTexdef(projection);
+ });
SceneChangeNotify();
}
void Scene_BrushSetTexdef_Component_Selected( scene::Graph& graph, const TextureProjection& projection ){
- Scene_ForEachSelectedBrushFace( graph, FaceSetTexdef( projection ) );
+ Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
+ face.SetTexdef(projection);
+ });
SceneChangeNotify();
}
-class FaceSetFlags
-{
-const ContentsFlagsValue& m_projection;
-public:
-FaceSetFlags( const ContentsFlagsValue& flags ) : m_projection( flags ){
-}
-void operator()( Face& face ) const {
- face.SetFlags( m_projection );
-}
-};
-
void Scene_BrushSetFlags_Selected( scene::Graph& graph, const ContentsFlagsValue& flags ){
- Scene_ForEachSelectedBrush_ForEachFace( graph, FaceSetFlags( flags ) );
+ Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
+ face.SetFlags(flags);
+ });
SceneChangeNotify();
}
void Scene_BrushSetFlags_Component_Selected( scene::Graph& graph, const ContentsFlagsValue& flags ){
- Scene_ForEachSelectedBrushFace( graph, FaceSetFlags( flags ) );
+ Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
+ face.SetFlags(flags);
+ });
SceneChangeNotify();
}
-class FaceShiftTexdef
-{
-float m_s, m_t;
-public:
-FaceShiftTexdef( float s, float t ) : m_s( s ), m_t( t ){
-}
-void operator()( Face& face ) const {
- face.ShiftTexdef( m_s, m_t );
-}
-};
-
void Scene_BrushShiftTexdef_Selected( scene::Graph& graph, float s, float t ){
- Scene_ForEachSelectedBrush_ForEachFace( graph, FaceShiftTexdef( s, t ) );
+ Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
+ face.ShiftTexdef(s, t);
+ });
SceneChangeNotify();
}
void Scene_BrushShiftTexdef_Component_Selected( scene::Graph& graph, float s, float t ){
- Scene_ForEachSelectedBrushFace( graph, FaceShiftTexdef( s, t ) );
+ Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
+ face.ShiftTexdef(s, t);
+ });
SceneChangeNotify();
}
-class FaceScaleTexdef
-{
-float m_s, m_t;
-public:
-FaceScaleTexdef( float s, float t ) : m_s( s ), m_t( t ){
-}
-void operator()( Face& face ) const {
- face.ScaleTexdef( m_s, m_t );
-}
-};
-
void Scene_BrushScaleTexdef_Selected( scene::Graph& graph, float s, float t ){
- Scene_ForEachSelectedBrush_ForEachFace( graph, FaceScaleTexdef( s, t ) );
+ Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
+ face.ScaleTexdef(s, t);
+ });
SceneChangeNotify();
}
void Scene_BrushScaleTexdef_Component_Selected( scene::Graph& graph, float s, float t ){
- Scene_ForEachSelectedBrushFace( graph, FaceScaleTexdef( s, t ) );
+ Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
+ face.ScaleTexdef(s, t);
+ });
SceneChangeNotify();
}
-class FaceRotateTexdef
-{
-float m_angle;
-public:
-FaceRotateTexdef( float angle ) : m_angle( angle ){
-}
-void operator()( Face& face ) const {
- face.RotateTexdef( m_angle );
-}
-};
-
void Scene_BrushRotateTexdef_Selected( scene::Graph& graph, float angle ){
- Scene_ForEachSelectedBrush_ForEachFace( graph, FaceRotateTexdef( angle ) );
+ Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
+ face.RotateTexdef(angle);
+ });
SceneChangeNotify();
}
void Scene_BrushRotateTexdef_Component_Selected( scene::Graph& graph, float angle ){
- Scene_ForEachSelectedBrushFace( graph, FaceRotateTexdef( angle ) );
+ Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
+ face.RotateTexdef(angle);
+ });
SceneChangeNotify();
}
-class FaceSetShader
-{
-const char* m_name;
-public:
-FaceSetShader( const char* name ) : m_name( name ) {}
-void operator()( Face& face ) const {
- face.SetShader( m_name );
-}
-};
-
void Scene_BrushSetShader_Selected( scene::Graph& graph, const char* name ){
- Scene_ForEachSelectedBrush_ForEachFace( graph, FaceSetShader( name ) );
+ Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
+ face.SetShader(name);
+ });
SceneChangeNotify();
}
void Scene_BrushSetShader_Component_Selected( scene::Graph& graph, const char* name ){
- Scene_ForEachSelectedBrushFace( graph, FaceSetShader( name ) );
+ Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
+ face.SetShader(name);
+ });
SceneChangeNotify();
}
-class FaceSetDetail
-{
-bool m_detail;
-public:
-FaceSetDetail( bool detail ) : m_detail( detail ){
-}
-void operator()( Face& face ) const {
- face.setDetail( m_detail );
-}
-};
-
void Scene_BrushSetDetail_Selected( scene::Graph& graph, bool detail ){
- Scene_ForEachSelectedBrush_ForEachFace( graph, FaceSetDetail( detail ) );
+ Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
+ face.setDetail(detail);
+ });
SceneChangeNotify();
}
return false;
}
-class FaceFindReplaceShader
-{
-const char* m_find;
-const char* m_replace;
-public:
-FaceFindReplaceShader( const char* find, const char* replace ) : m_find( find ), m_replace( replace ){
-}
-void operator()( Face& face ) const {
- Face_FindReplaceShader( face, m_find, m_replace );
-}
-};
-
-class FaceFindShader
-{
-const char* m_find;
-const char* m_replace;
-public:
-FaceFindShader( const char* find ) : m_find( find ){
-}
-void operator()( FaceInstance& faceinst ) const {
- if ( shader_equal( faceinst.getFace().GetShader(), m_find ) ) {
- faceinst.setSelected( SelectionSystem::eFace, true );
- }
-}
-};
-
bool DoingSearch( const char *repl ){
return ( repl == NULL || ( strcmp( "textures/", repl ) == 0 ) );
}
void Scene_BrushFindReplaceShader( scene::Graph& graph, const char* find, const char* replace ){
if ( DoingSearch( replace ) ) {
- Scene_ForEachBrush_ForEachFaceInstance( graph, FaceFindShader( find ) );
+ Scene_ForEachBrush_ForEachFaceInstance(graph, [&](FaceInstance &faceinst) {
+ if (shader_equal(faceinst.getFace().GetShader(), find)) {
+ faceinst.setSelected(SelectionSystem::eFace, true);
+ }
+ });
}
else
{
- Scene_ForEachBrush_ForEachFace( graph, FaceFindReplaceShader( find, replace ) );
+ Scene_ForEachBrush_ForEachFace(graph, [&](Face &face) { Face_FindReplaceShader(face, find, replace); });
}
}
void Scene_BrushFindReplaceShader_Selected( scene::Graph& graph, const char* find, const char* replace ){
if ( DoingSearch( replace ) ) {
- Scene_ForEachSelectedBrush_ForEachFaceInstance( graph,
- FaceFindShader( find ) );
+ Scene_ForEachSelectedBrush_ForEachFaceInstance(graph, [&](FaceInstance &faceinst) {
+ if (shader_equal(faceinst.getFace().GetShader(), find)) {
+ faceinst.setSelected(SelectionSystem::eFace, true);
+ }
+ });
}
else
{
- Scene_ForEachSelectedBrush_ForEachFace( graph,
- FaceFindReplaceShader( find, replace ) );
+ Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
+ Face_FindReplaceShader(face, find, replace);
+ });
}
}
}
else
{
- Scene_ForEachSelectedBrushFace( graph, FaceFindReplaceShader( find, replace ) );
+ Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
+ Face_FindReplaceShader(face, find, replace);
+ });
}
}
-class FaceFitTexture
-{
-float m_s_repeat, m_t_repeat;
-public:
-FaceFitTexture( float s_repeat, float t_repeat ) : m_s_repeat( s_repeat ), m_t_repeat( t_repeat ){
-}
-void operator()( Face& face ) const {
- face.FitTexture( m_s_repeat, m_t_repeat );
-}
-};
-
void Scene_BrushFitTexture_Selected( scene::Graph& graph, float s_repeat, float t_repeat ){
- Scene_ForEachSelectedBrush_ForEachFace( graph, FaceFitTexture( s_repeat, t_repeat ) );
+ Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
+ face.FitTexture(s_repeat, t_repeat);
+ });
SceneChangeNotify();
}
void Scene_BrushFitTexture_Component_Selected( scene::Graph& graph, float s_repeat, float t_repeat ){
- Scene_ForEachSelectedBrushFace( graph, FaceFitTexture( s_repeat, t_repeat ) );
+ Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
+ face.FitTexture(s_repeat, t_repeat);
+ });
SceneChangeNotify();
}
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 ){
- Scene_ForEachSelectedBrush_ForEachFaceInstance( graph, FaceSelectByShader( name ) );
-}
-
-class FaceGetTexdef
-{
-TextureProjection& m_projection;
-mutable bool m_done;
-public:
-FaceGetTexdef( TextureProjection& projection )
- : m_projection( projection ), m_done( false ){
-}
-void operator()( Face& face ) const {
- if ( !m_done ) {
- m_done = true;
- face.GetTexdef( m_projection );
- }
+ Scene_ForEachSelectedBrush_ForEachFaceInstance(graph, [&](FaceInstance &face) {
+ printf("checking %s = %s\n", face.getFace().GetShader(), name);
+ if (shader_equal(face.getFace().GetShader(), name)) {
+ face.setSelected(SelectionSystem::eFace, true);
+ }
+ });
}
-};
-
void Scene_BrushGetTexdef_Selected( scene::Graph& graph, TextureProjection& projection ){
- Scene_ForEachSelectedBrush_ForEachFace( graph, FaceGetTexdef( projection ) );
+ bool done = false;
+ Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
+ if (!done) {
+ done = true;
+ face.GetTexdef(projection);
+ }
+ });
}
void Scene_BrushGetTexdef_Component_Selected( scene::Graph& graph, TextureProjection& projection ){
}
-class FaceGetFlags
-{
-ContentsFlagsValue& m_flags;
-mutable bool m_done;
-public:
-FaceGetFlags( ContentsFlagsValue& flags )
- : m_flags( flags ), m_done( false ){
-}
-void operator()( Face& face ) const {
- if ( !m_done ) {
- m_done = true;
- face.GetFlags( m_flags );
- }
-}
-};
-
-
void Scene_BrushGetFlags_Selected( scene::Graph& graph, ContentsFlagsValue& flags ){
#if 1
if ( GlobalSelectionSystem().countSelected() != 0 ) {
BrushInstance* brush = Instance_getBrush( GlobalSelectionSystem().ultimateSelected() );
if ( brush != 0 ) {
- Brush_forEachFace( *brush, FaceGetFlags( flags ) );
+ bool done = false;
+ Brush_forEachFace(*brush, [&](Face &face) {
+ if (!done) {
+ done = true;
+ face.GetFlags(flags);
+ }
+ });
}
}
#else
}
-class FaceGetShader
-{
-CopiedString& m_shader;
-mutable bool m_done;
-public:
-FaceGetShader( CopiedString& shader )
- : m_shader( shader ), m_done( false ){
-}
-void operator()( Face& face ) const {
- if ( !m_done ) {
- m_done = true;
- m_shader = face.GetShader();
- }
-}
-};
-
void Scene_BrushGetShader_Selected( scene::Graph& graph, CopiedString& shader ){
#if 1
if ( GlobalSelectionSystem().countSelected() != 0 ) {
BrushInstance* brush = Instance_getBrush( GlobalSelectionSystem().ultimateSelected() );
if ( brush != 0 ) {
- Brush_forEachFace( *brush, FaceGetShader( shader ) );
+ bool done = false;
+ Brush_forEachFace(*brush, [&](Face &face) {
+ if (!done) {
+ done = true;
+ shader = face.GetShader();
+ }
+ });
}
}
#else
-class FaceFilterAny
-{
-FaceFilter* m_filter;
-bool& m_filtered;
-public:
-FaceFilterAny( FaceFilter* filter, bool& filtered ) : m_filter( filter ), m_filtered( filtered ){
- m_filtered = false;
-}
-void operator()( Face& face ) const {
- if ( m_filter->filter( face ) ) {
- m_filtered = true;
- }
-}
-};
-
class filter_brush_any_face : public BrushFilter
{
FaceFilter* m_filter;
filter_brush_any_face( FaceFilter* filter ) : m_filter( filter ){
}
bool filter( const Brush& brush ) const {
- bool filtered;
- Brush_forEachFace( brush, FaceFilterAny( m_filter, filtered ) );
+ bool filtered = false;
+ Brush_forEachFace(brush, [&](Face &face) {
+ if (m_filter->filter(face)) {
+ filtered = true;
+ }
+ });
return filtered;
}
};
-class FaceFilterAll
-{
-FaceFilter* m_filter;
-bool& m_filtered;
-public:
-FaceFilterAll( FaceFilter* filter, bool& filtered ) : m_filter( filter ), m_filtered( filtered ){
- m_filtered = true;
-}
-void operator()( Face& face ) const {
- if ( !m_filter->filter( face ) ) {
- m_filtered = false;
- }
-}
-};
-
class filter_brush_all_faces : public BrushFilter
{
FaceFilter* m_filter;
filter_brush_all_faces( FaceFilter* filter ) : m_filter( filter ){
}
bool filter( const Brush& brush ) const {
- bool filtered;
- Brush_forEachFace( brush, FaceFilterAll( m_filter, filtered ) );
+ bool filtered = true;
+ Brush_forEachFace(brush, [&](Face &face) {
+ if (!m_filter->filter(face)) {
+ filtered = false;
+ }
+ });
return filtered;
}
};
}
-class BuildPairEqual
-{
-const char* m_name;
-public:
-BuildPairEqual( const char* name ) : m_name( name ){
-}
-bool operator()( const BuildPair& self ) const {
- return string_equal( self.first.c_str(), m_name );
-}
-};
-
typedef std::list<BuildPair> Project;
Project::iterator Project_find( Project& project, const char* name ){
- return std::find_if( project.begin(), project.end(), BuildPairEqual( name ) );
+ return std::find_if(project.begin(), project.end(), [&](const BuildPair &self) {
+ return string_equal(self.first.c_str(), name);
+ });
}
Project::iterator Project_find( Project& project, std::size_t index ){
}
}
-class FaceMakeBrush
-{
-const Brush& brush;
-brush_vector_t& out;
-float offset;
-public:
-FaceMakeBrush( const Brush& brush, brush_vector_t& out, float offset )
- : brush( brush ), out( out ), offset( offset ){
-}
-void operator()( Face& face ) const {
- Face_makeBrush( face, brush, out, offset );
-}
-};
-
void Brush_makeHollow( const Brush& brush, brush_vector_t& out, float offset ){
- Brush_forEachFace( brush, FaceMakeBrush( brush, out, offset ) );
+ Brush_forEachFace(brush, [&](Face &face) {
+ Face_makeBrush(face, brush, out, offset);
+ });
}
class BrushHollowSelectedWalker : public scene::Graph::Walker
typedef std::map<CopiedString, const char*, PathLess> Paths;
-class PathsInsert
-{
-Paths& m_paths;
-const char* m_directory;
-public:
-PathsInsert( Paths& paths, const char* directory ) : m_paths( paths ), m_directory( directory ){
-}
-void operator()( const char* name ) const {
- m_paths.insert( Paths::value_type( name, m_directory ) );
-}
-};
-
-
void EntityClassQuake3_constructDirectory( const char* directory, const char* extension, Paths& paths ){
globalOutputStream() << "EntityClass: searching " << makeQuoted( directory ) << " for *." << extension << '\n';
- Directory_forEach( directory, matchFileExtension( extension, PathsInsert( paths, directory ) ) );
+ Directory_forEach(directory, matchFileExtension(extension, [&](const char *name) {
+ paths.insert(Paths::value_type(name, directory));
+ }));
}
#include "os/dir.h"
-class CLoadModule
-{
-const char* m_path;
-public:
-CLoadModule( const char* path ) : m_path( path ){
-}
-void operator()( const char* name ) const {
- char fullname[1024];
- ASSERT_MESSAGE( strlen( m_path ) + strlen( name ) < 1024, "" );
- strcpy( fullname, m_path );
- strcat( fullname, name );
- globalOutputStream() << "Found '" << fullname << "'\n";
- GlobalModuleServer_loadModule( fullname );
-}
-};
-
const char* const c_library_extension =
#if defined( CMAKE_SHARED_MODULE_SUFFIX )
CMAKE_SHARED_MODULE_SUFFIX
;
void Radiant_loadModules( const char* path ){
- Directory_forEach( path, MatchFileExtension<CLoadModule>( c_library_extension, CLoadModule( path ) ) );
+ Directory_forEach(path, matchFileExtension(c_library_extension, [&](const char *name) {
+ char fullname[1024];
+ ASSERT_MESSAGE(strlen(path) + strlen(name) < 1024, "");
+ strcpy(fullname, path);
+ strcat(fullname, name);
+ globalOutputStream() << "Found '" << fullname << "'\n";
+ GlobalModuleServer_loadModule(fullname);
+ }));
}
void Radiant_loadModulesFromRoot( const char* directory ){
#endif
}
-class PatchSetFixedSubdivisions
-{
-const PatchFixedSubdivisions& m_subdivisions;
-public:
-PatchSetFixedSubdivisions( const PatchFixedSubdivisions& subdivisions ) : m_subdivisions( subdivisions ){
-}
-void operator()( Patch& patch ) const {
- Patch_setFixedSubdivisions( patch, m_subdivisions );
-}
-};
-
void Scene_PatchSetFixedSubdivisions( const PatchFixedSubdivisions& subdivisions ){
UndoableCommand command( "patchSetFixedSubdivisions" );
- Scene_forEachVisibleSelectedPatch( PatchSetFixedSubdivisions( subdivisions ) );
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ Patch_setFixedSubdivisions(patch, subdivisions);
+ });
}
g_PatchInspector.importData();
}
-class PatchSetTextureRepeat
-{
-float m_s, m_t;
-public:
-PatchSetTextureRepeat( float s, float t ) : m_s( s ), m_t( t ){
-}
-void operator()( Patch& patch ) const {
- patch.SetTextureRepeat( m_s, m_t );
-}
-};
-
void Scene_PatchTileTexture_Selected( scene::Graph& graph, float s, float t ){
- Scene_forEachVisibleSelectedPatch( PatchSetTextureRepeat( s, t ) );
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.SetTextureRepeat(s, t);
+ });
SceneChangeNotify();
}
Patch_FlipTextureY();
}
-struct PatchRotateTexture
-{
- float m_angle;
-public:
- PatchRotateTexture( float angle ) : m_angle( angle ){
- }
- void operator()( Patch& patch ) const {
- patch.RotateTexture( m_angle );
- }
-};
-
void Scene_PatchRotateTexture_Selected( scene::Graph& graph, float angle ){
- Scene_forEachVisibleSelectedPatch( PatchRotateTexture( angle ) );
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.RotateTexture(angle);
+ });
}
-class PatchScaleTexture
-{
-float m_s, m_t;
-public:
-PatchScaleTexture( float s, float t ) : m_s( s ), m_t( t ){
-}
-void operator()( Patch& patch ) const {
- patch.ScaleTexture( m_s, m_t );
-}
-};
-
float Patch_convertScale( float scale ){
if ( scale > 0 ) {
return scale;
}
void Scene_PatchScaleTexture_Selected( scene::Graph& graph, float s, float t ){
- Scene_forEachVisibleSelectedPatch( PatchScaleTexture( Patch_convertScale( s ), Patch_convertScale( t ) ) );
+ s = Patch_convertScale(s);
+ t = Patch_convertScale(t);
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.ScaleTexture(s, t);
+ });
}
-class PatchTranslateTexture
-{
-float m_s, m_t;
-public:
-PatchTranslateTexture( float s, float t )
- : m_s( s ), m_t( t ){
-}
-void operator()( Patch& patch ) const {
- patch.TranslateTexture( m_s, m_t );
-}
-};
-
void Scene_PatchTranslateTexture_Selected( scene::Graph& graph, float s, float t ){
- Scene_forEachVisibleSelectedPatch( PatchTranslateTexture( s, t ) );
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.TranslateTexture(s, t);
+ });
}
static void OnBtnPatchAutoCap( ui::Widget widget, gpointer data ){
typedef std::vector<scene::Instance*> InstanceVector;
-class PatchStoreInstance
-{
-InstanceVector& m_instances;
-public:
-PatchStoreInstance( InstanceVector& instances ) : m_instances( instances ){
-}
-void operator()( PatchInstance& patch ) const {
- m_instances.push_back( &patch );
-}
-};
-
enum ECapDialog {
PATCHCAP_BEVEL = 0,
PATCHCAP_ENDCAP,
}
InstanceVector instances;
- Scene_forEachVisibleSelectedPatchInstance( PatchStoreInstance( instances ) );
+ Scene_forEachVisibleSelectedPatchInstance([&](PatchInstance &patch) {
+ instances.push_back(&patch);
+ });
for ( InstanceVector::const_iterator i = instances.begin(); i != instances.end(); ++i )
{
Patch_makeCaps( *Node_getPatch( ( *i )->path().top() ), *( *i ), eType, shader );
}
-class PatchCapTexture
-{
-public:
-void operator()( Patch& patch ) const {
- patch.ProjectTexture( Patch::m_CycleCapIndex );
-}
-};
-
void Scene_PatchCapTexture_Selected( scene::Graph& graph ){
- Scene_forEachVisibleSelectedPatch( PatchCapTexture() );
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.ProjectTexture(Patch::m_CycleCapIndex);
+ });
Patch::m_CycleCapIndex = ( Patch::m_CycleCapIndex == 0 ) ? 1 : ( Patch::m_CycleCapIndex == 1 ) ? 2 : 0;
SceneChangeNotify();
}
-class PatchFlipTexture
-{
-int m_axis;
-public:
-PatchFlipTexture( int axis ) : m_axis( axis ){
-}
-void operator()( Patch& patch ) const {
- patch.FlipTexture( m_axis );
-}
-};
-
void Scene_PatchFlipTexture_Selected( scene::Graph& graph, int axis ){
- Scene_forEachVisibleSelectedPatch( PatchFlipTexture( axis ) );
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.FlipTexture(axis);
+ });
}
-class PatchNaturalTexture
-{
-public:
-void operator()( Patch& patch ) const {
- patch.NaturalTexture();
-}
-};
-
void Scene_PatchNaturalTexture_Selected( scene::Graph& graph ){
- Scene_forEachVisibleSelectedPatch( PatchNaturalTexture() );
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.NaturalTexture();
+ });
SceneChangeNotify();
}
-class PatchInsertRemove
-{
-bool m_insert, m_column, m_first;
-public:
-PatchInsertRemove( bool insert, bool column, bool first ) : m_insert( insert ), m_column( column ), m_first( first ){
-}
-void operator()( Patch& patch ) const {
- patch.InsertRemove( m_insert, m_column, m_first );
-}
-};
-
void Scene_PatchInsertRemove_Selected( scene::Graph& graph, bool bInsert, bool bColumn, bool bFirst ){
- Scene_forEachVisibleSelectedPatch( PatchInsertRemove( bInsert, bColumn, bFirst ) );
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.InsertRemove(bInsert, bColumn, bFirst);
+ });
}
-class PatchInvertMatrix
-{
-public:
-void operator()( Patch& patch ) const {
- patch.InvertMatrix();
-}
-};
-
void Scene_PatchInvert_Selected( scene::Graph& graph ){
- Scene_forEachVisibleSelectedPatch( PatchInvertMatrix() );
-}
-
-class PatchRedisperse
-{
-EMatrixMajor m_major;
-public:
-PatchRedisperse( EMatrixMajor major ) : m_major( major ){
-}
-void operator()( Patch& patch ) const {
- patch.Redisperse( m_major );
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.InvertMatrix();
+ });
}
-};
void Scene_PatchRedisperse_Selected( scene::Graph& graph, EMatrixMajor major ){
- Scene_forEachVisibleSelectedPatch( PatchRedisperse( major ) );
-}
-
-class PatchSmooth
-{
-EMatrixMajor m_major;
-public:
-PatchSmooth( EMatrixMajor major ) : m_major( major ){
-}
-void operator()( Patch& patch ) const {
- patch.Smooth( m_major );
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.Redisperse(major);
+ });
}
-};
void Scene_PatchSmooth_Selected( scene::Graph& graph, EMatrixMajor major ){
- Scene_forEachVisibleSelectedPatch( PatchSmooth( major ) );
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.Smooth(major);
+ });
}
-class PatchTransposeMatrix
-{
-public:
-void operator()( Patch& patch ) const {
- patch.TransposeMatrix();
-}
-};
-
void Scene_PatchTranspose_Selected( scene::Graph& graph ){
- Scene_forEachVisibleSelectedPatch( PatchTransposeMatrix() );
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.TransposeMatrix();
+ });
}
-class PatchSetShader
-{
-const char* m_name;
-public:
-PatchSetShader( const char* name )
- : m_name( name ){
-}
-void operator()( Patch& patch ) const {
- patch.SetShader( m_name );
-}
-};
-
void Scene_PatchSetShader_Selected( scene::Graph& graph, const char* name ){
- Scene_forEachVisibleSelectedPatch( PatchSetShader( name ) );
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.SetShader(name);
+ });
SceneChangeNotify();
}
}
}
-class PatchSelectByShader
-{
-const char* m_name;
-public:
-inline PatchSelectByShader( const char* name )
- : m_name( name ){
-}
-void operator()( PatchInstance& patch ) const {
- if ( shader_equal( patch.getPatch().GetShader(), m_name ) ) {
- patch.setSelected( true );
- }
-}
-};
-
void Scene_PatchSelectByShader( scene::Graph& graph, const char* name ){
- Scene_forEachVisiblePatchInstance( PatchSelectByShader( name ) );
+ Scene_forEachVisiblePatchInstance([&](PatchInstance &patch) {
+ if (shader_equal(patch.getPatch().GetShader(), name)) {
+ patch.setSelected(true);
+ }
+ });
}
-class PatchFindReplaceShader
-{
-const char* m_find;
-const char* m_replace;
-public:
-PatchFindReplaceShader( const char* find, const char* replace ) : m_find( find ), m_replace( replace ){
-}
-void operator()( Patch& patch ) const {
- if ( shader_equal( patch.GetShader(), m_find ) ) {
- patch.SetShader( m_replace );
- }
-}
-};
-
void Scene_PatchFindReplaceShader( scene::Graph& graph, const char* find, const char* replace ){
- Scene_forEachVisiblePatch( PatchFindReplaceShader( find, replace ) );
+ Scene_forEachVisiblePatch([&](Patch &patch) {
+ if (shader_equal(patch.GetShader(), find)) {
+ patch.SetShader(replace);
+ }
+ });
}
void Scene_PatchFindReplaceShader_Selected( scene::Graph& graph, const char* find, const char* replace ){
- Scene_forEachVisibleSelectedPatch( PatchFindReplaceShader( find, replace ) );
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ if (shader_equal(patch.GetShader(), find)) {
+ patch.SetShader(replace);
+ }
+ });
}
return create_simple_modal_dialog_window( "Global Preferences", m_modal, frame );
}
-class LoadGameFile
-{
-std::list<CGameDescription*>& mGames;
-const char* mPath;
-public:
-LoadGameFile( std::list<CGameDescription*>& games, const char* path ) : mGames( games ), mPath( path ){
-}
-void operator()( const char* name ) const {
- if ( !extension_equal( path_get_extension( name ), "game" ) ) {
- return;
- }
- StringOutputStream strPath( 256 );
- strPath << mPath << name;
- globalOutputStream() << strPath.c_str() << '\n';
-
- xmlDocPtr pDoc = xmlParseFile( strPath.c_str() );
- if ( pDoc ) {
- mGames.push_front( new CGameDescription( pDoc, name ) );
- xmlFreeDoc( pDoc );
- }
- else
- {
- globalErrorStream() << "XML parser failed on '" << strPath.c_str() << "'\n";
- }
-}
-};
-
void CGameDialog::ScanForGames(){
StringOutputStream strGamesPath( 256 );
strGamesPath << AppPath_get() << "games/";
(if that's really needed)
*/
- Directory_forEach( path, LoadGameFile( mGames, path ) );
+ Directory_forEach(path, [&](const char *name) {
+ if (!extension_equal(path_get_extension(name), "game")) {
+ return;
+ }
+ StringOutputStream strPath(256);
+ strPath << path << name;
+ globalOutputStream() << strPath.c_str() << '\n';
+
+ xmlDocPtr pDoc = xmlParseFile(strPath.c_str());
+ if (pDoc) {
+ mGames.push_front(new CGameDescription(pDoc, name));
+ xmlFreeDoc(pDoc);
+ } else {
+ globalErrorStream() << "XML parser failed on '" << strPath.c_str() << "'\n";
+ }
+ });
}
CGameDescription* CGameDialog::GameDescriptionForComboItem(){
#include "instancelib.h"
#include "treemodel.h"
-class StringEqualPredicate
-{
-const char* m_string;
-public:
-StringEqualPredicate( const char* string ) : m_string( string ){
-}
-bool operator()( const char* other ) const {
- return string_equal( m_string, other );
-}
-};
-
template<std::size_t SIZE>
class TypeIdMap
{
TypeIdMap() : m_typeNamesEnd( m_typeNames ){
}
TypeId getTypeId( const char* name ){
- TypeName* i = std::find_if( m_typeNames, m_typeNamesEnd, StringEqualPredicate( name ) );
+ TypeName *i = std::find_if(m_typeNames, m_typeNamesEnd, [&](const char *other) {
+ return string_equal(name, other);
+ });
if ( i == m_typeNamesEnd ) {
ASSERT_MESSAGE( m_typeNamesEnd != m_typeNames + SIZE, "reached maximum number of type names supported (" << Unsigned( SIZE ) << ")" );
*m_typeNamesEnd++ = name;