コード例 #1
0
void FileDialogDisplayer::DisplayFileDialog( const Helium::FileDialogArgs& args )
{
    int32_t style = 0;

    switch ( args.m_Type )
    {
    case FileDialogTypes::OpenFile:
        style = FileDialogStyles::DefaultOpen;
        break;

    case FileDialogTypes::SaveFile:
        style = FileDialogStyles::DefaultSave;
        break;

    default:
        HELIUM_ASSERT( false );
    }

    FileDialog saveDlg( NULL, args.m_Caption.c_str(), args.m_DefaultDirectory.c_str(), args.m_DefaultFile.c_str(), TXT( "" ),  style );

    saveDlg.AddFilter( args.m_Filters );

    Helium::Path path;

    if ( saveDlg.ShowModal() == wxID_OK )
    {
        path.Set( saveDlg.GetFilePath() );
    }

    args.m_Result = path;
}
コード例 #2
0
/////////////////////////////////////////////////////////////////////////////
// Helper function to convert a file ref to an appropriate string 
// representation.
// 
tstring Editor::PathToLabel( const Helium::Path& path, const FilePathOption filePathOption )
{
    tstring filePath = path.Get();

    // Determine whether to show full path or not...
    if ( !filePath.empty() )
    {
        switch ( filePathOption )
        {
        case FilePathOptions::Basename:
            filePath = path.Basename();
            break;

        case FilePathOptions::Filename:
            filePath = path.Filename();
            break;

        case FilePathOptions::PartialPath:
            //FileSystem::StripPrefix( Finder::ProjectAssets(), filePath );
#pragma TODO( "Make this aware of the project root somehow, maybe the application/program options" )
            break;

        case FilePathOptions::FullPath:
            // Do nothing, it's already good to go
            break;
        }
    }

    return filePath;
}
コード例 #3
0
ファイル: MeshAssetFactory.cpp プロジェクト: goofoo/Helium
AssetClassPtr MeshAssetFactory::Create( const Helium::Path& path )
{
    Helium::Path assetPath = path;
    assetPath.ReplaceExtension( TXT( "entity.nrb" ) );

    if ( assetPath.Exists() )
    {
        return AssetClass::LoadAssetClass( assetPath );
    }

    EntityPtr entity = new Entity();
    entity->SetPath( path.Filename() ); // we're dropping this guy relative to the data file

    MeshProcessingComponentPtr meshProcessingComponent = new MeshProcessingComponent();
    entity->SetComponent( meshProcessingComponent );

    try
    {
        Reflect::Archive::ToFile( entity, assetPath );
        entity->SetSerializationPath( assetPath );
    }
    catch( Helium::Exception& )
    {
        delete entity;
        return NULL;
    }

    return entity;
}
コード例 #4
0
ファイル: ProjectViewModel.cpp プロジェクト: euler0/Helium
void ProjectViewModelNode::SetPath( const Helium::Path& path )
{
    if ( _tcsicmp( m_Path.c_str(), path.c_str() ) != 0 )
    {
        m_Path = path;
    }
}
コード例 #5
0
ファイル: ProjectViewModel.cpp プロジェクト: euler0/Helium
bool ProjectViewModel::RemoveChildItem( const wxDataViewItem& parenItem, const Helium::Path& path )
{
    ProjectViewModelNode *parentNode = static_cast< ProjectViewModelNode* >( parenItem.GetID() );
    if ( !parentNode )
    {
        HELIUM_ASSERT( m_RootNode );
        parentNode = m_RootNode.Ptr();
    }

    S_ProjectViewModelNodeChildren::const_iterator foundChild = parentNode->GetChildren().end();
    for ( S_ProjectViewModelNodeChildren::const_iterator itr = parentNode->GetChildren().begin(),
        end = parentNode->GetChildren().end(); itr != end; ++itr )
    {
        if ( _tcsicmp( (*itr)->GetPath().Get().c_str(), path.Get().c_str() ) == 0 )
        {
            foundChild = itr;
            break;
        }
    }

    if ( foundChild != parentNode->GetChildren().end() )
    {
        RemoveItem( wxDataViewItem( (void*)(*foundChild) ) );

        return true;
    }
    return false;
}
コード例 #6
0
ファイル: Path.cpp プロジェクト: andyburke/Replicant
Helium::Path Path::GetRelativePath( const Helium::Path& basisPath ) const
{
    std::vector< tstring > targetDirectories = this->DirectoryAsVector();
    std::vector< tstring > baseDirectories = basisPath.DirectoryAsVector();

    size_t i = 0;
    while( targetDirectories.size() > i && baseDirectories.size() > i && ( targetDirectories[ i ] == baseDirectories[ i ] ) )
    {
        ++i;
    }

    if ( i == 0 )
    {
        return *this;
    }

    tstring newPathString;
    for ( size_t j = 0; j < ( baseDirectories.size() - i ); ++j )
    {
        newPathString += tstring( TXT( ".." ) ) + s_InternalPathSeparator;
    }

    for ( size_t j = i; j < targetDirectories.size(); ++j )
    {
        newPathString += targetDirectories[ j ] + s_InternalPathSeparator;
    }

    newPathString += Filename();
    return Helium::Path( newPathString );
}
コード例 #7
0
ファイル: Path.cpp プロジェクト: andyburke/Replicant
Helium::Path Path::GetAbsolutePath( const Helium::Path& basisPath ) const
{
    HELIUM_ASSERT( !IsAbsolute() ); // shouldn't call this on an already-absolute path

    tstring newPathString;
    Helium::GetFullPath( tstring( basisPath.Directory() + m_Path ).c_str(), newPathString );
    return Helium::Path( newPathString );
}
コード例 #8
0
ファイル: Preferences.cpp プロジェクト: euler0/Helium
bool Helium::GetPreferencesDirectory( Helium::Path& preferencesDirectory )
{
    tstring prefDirectory;

    if ( !Helium::GetPreferencesDirectory( prefDirectory ) )
    {
        return false;
    }

    prefDirectory += TXT( "/.Helium/" );
    
    preferencesDirectory.Set( prefDirectory );
    return true;
}
コード例 #9
0
tstring DetailsColumn::Size( const Helium::Path& path )
{
    i64 size = path.Size();

    tstringstream printSize;
    if ( size == 0 )
    {
      printSize << "0 KB";
    }
    else if ( size <= 1024 )
    {
      printSize << "1 KB";
    }
    else
    {
      size = size / 1024;
      printSize << size << " KB";
    }

    return printSize.str().c_str();
}
コード例 #10
0
ファイル: ProjectViewModel.cpp プロジェクト: euler0/Helium
bool ProjectViewModel::AddChildItem( const wxDataViewItem& parenItem, const Helium::Path& path )
{
    // Get the parent node
    ProjectViewModelNode *parentNode = static_cast< ProjectViewModelNode* >( parenItem.GetID() );
    if ( !parentNode )
    {
        HELIUM_ASSERT( m_RootNode );
        parentNode = m_RootNode.Ptr();
    }

    bool isContainer = path.HasExtension( TXT( "HeliumScene" ) );

    // Create the child node
    const Document* document = m_DocumentManager->FindDocument( path );
    Helium::StdInsert<S_ProjectViewModelNodeChildren>::Result inserted = parentNode->GetChildren().insert( new ProjectViewModelNode( this, parentNode, path, document, isContainer ) );
    if ( inserted.second )
    {
        ProjectViewModelNode* childNode = (*inserted.first);

        // See if the document is already open
        //MM_ProjectViewModelNodesByPath::iterator findNode = m_MM_ProjectViewModelNodesByPath.find( path );
        //if ( findNode != m_MM_ProjectViewModelNodesByPath.end()
        //    && findNode->first == path
        //    && findNode->second->GetDocument() ) 
        //{
        //    childNode->ConnectDocument( findNode->second->GetDocument() );
        //}

        // Add the node to the multimap and call ItemAdded
        m_MM_ProjectViewModelNodesByPath.insert( MM_ProjectViewModelNodesByPath::value_type( path, childNode ));
        if ( parentNode == m_RootNode.Ptr() )
        {
            parentNode = NULL;
        }
        ItemAdded( (void*)parentNode, (void*)childNode );

        return true;
    }
    return false;
}
コード例 #11
0
tstring DetailsColumn::Path( const Helium::Path& path )
{
    return path.Get();
}
コード例 #12
0
ファイル: Path.cpp プロジェクト: andyburke/Replicant
bool Path::Copy( const Helium::Path& target, bool overwrite ) const
{
    return Helium::Copy( Native().c_str(), target.Native().c_str(), overwrite );
}
コード例 #13
0
tstring DetailsColumn::Directory( const Helium::Path& path )
{
    return path.Directory();
}
コード例 #14
0
tstring DetailsColumn::Filename( const Helium::Path& path )
{
    return path.Filename();
}
コード例 #15
0
ファイル: Path.cpp プロジェクト: andyburke/Replicant
bool Path::Move( const Helium::Path& target ) const 
{
    return Helium::Move( Native().c_str(), target.Native().c_str() );
}
コード例 #16
0
void* ThumbnailLoader::LoadThread::Entry()
{
#ifdef HELIUM_ASSERT_ENABLED
    bool emptyQueuePollingCheck = false;
#endif

    while ( true )
    {
        m_Loader.m_Signal.Decrement();

        if ( m_Loader.m_Quit )
        {
            break;
        }

        // the device is gone, our glorious benefactor is probably cleaning up
        IDirect3DDevice9* device = m_Loader.m_DeviceManager->GetD3DDevice();
        if ( !device )
        {
            // You should stop this thread before letting go of the window that
            // owns the device.
            HELIUM_BREAK();
            break;
        }

        // while the device is lost, just wait for it to come back
        while ( device->TestCooperativeLevel() != D3D_OK )
        {
            if ( m_Loader.m_Quit )
            {
                break;
            }

            wxThread::Sleep( 100 );
            continue;
        }

        if ( m_Loader.m_Quit )
        {
            break;
        }

        Helium::Path path;

        {
            Helium::Locker< Helium::OrderedSet< Helium::Path > >::Handle queue( m_Loader.m_FileQueue );
            if ( !queue->Empty() )
            {
#ifdef HELIUM_ASSERT_ENABLED
                emptyQueuePollingCheck = false;
#endif
                path = queue->Front();
            }
            else
            {
                // if you hit this then the bookkeeping of the counting semaphore is broken
                HELIUM_ASSERT( !emptyQueuePollingCheck );

#ifdef HELIUM_ASSERT_ENABLED
                emptyQueuePollingCheck = true;
#endif
                continue;
            }

            queue->Remove( path );
        }

        ResultArgs args;
        args.m_Path = path;
        args.m_Cancelled = false;

        if ( SceneGraph::IsSupportedTexture( path.Get() ) )
        {
            IDirect3DTexture9* texture = NULL;
            if ( texture = LoadTexture( device, path.Get() ) )
            {
                ThumbnailPtr thumbnail = new Thumbnail( m_Loader.m_DeviceManager, texture );
                args.m_Textures.push_back( thumbnail );
            }
        }
        else
        {
#pragma TODO( "When we store the thumbnail in the asset file, fix this." )

            if ( path.Extension() == TXT( "HeliumEntity" ) )
            {
                Path thumbnailPath( path.Directory() + path.Basename() + TXT( "_thumbnail.png" ) );

                if ( thumbnailPath.Exists() )
                {
                    IDirect3DTexture9* texture = NULL;
                    if ( texture = LoadTexture( device, thumbnailPath.Get() ) )
                    {
                        ThumbnailPtr thumbnail = new Thumbnail( m_Loader.m_DeviceManager, texture );
                        args.m_Textures.push_back( thumbnail );
                    }
                }
            }
            // Include the color map of a shader as a possible thumbnail image
            else if ( path.Extension() == TXT( "HeliumShader" ) )
            {
                Asset::ShaderAssetPtr shader = NULL;
                try
                {
                    shader = Asset::AssetClass::LoadAssetClass< Asset::ShaderAsset >( path );
                }
                catch( const Exception& )
                {
                    shader = NULL;
                }

                if ( shader )
                {
                    Asset::TexturePtr colorMap = Asset::AssetClass::LoadAssetClass< Asset::Texture >( shader->m_ColorMapPath );
                    if ( colorMap.ReferencesObject() )
                    {
                        if ( colorMap->GetContentPath().Exists() && SceneGraph::IsSupportedTexture( colorMap->GetContentPath().Get() ) )
                        {
                            IDirect3DTexture9* texture = NULL;
                            if ( texture = LoadTexture( device, colorMap->GetContentPath().Get() ) )
                            {
                                ThumbnailPtr thumbnail = new Thumbnail( m_Loader.m_DeviceManager, texture );
                                args.m_Textures.push_back( thumbnail );
                            }
                        }
                    }
                }
            }
            else if ( path.Extension() == TXT( "HeliumTexture" ) )
            {
                Asset::TexturePtr textureAsset = NULL;
                
                try
                {
                    textureAsset = Asset::AssetClass::LoadAssetClass< Asset::Texture >( path );
                }
                catch( const Exception& )
                {
                    textureAsset = NULL;
                }

                if ( textureAsset.ReferencesObject() )
                {
                    if ( textureAsset->GetContentPath().Exists() && SceneGraph::IsSupportedTexture( textureAsset->GetContentPath().Get() ) )
                    {
                        IDirect3DTexture9* texture = NULL;
                        if ( texture = LoadTexture( device, textureAsset->GetContentPath().Get() ) )
                        {
                            ThumbnailPtr thumbnail = new Thumbnail( m_Loader.m_DeviceManager, texture );
                            args.m_Textures.push_back( thumbnail );
                        }
                    }
                }
            }
        }

        m_Loader.m_Result.Raise( args );
    }

    return NULL;
}
コード例 #17
0
ファイル: Path.cpp プロジェクト: andyburke/Replicant
Helium::Path Path::operator+( const Helium::Path& rhs ) const
{
    // you shouldn't use this on an absolute path
    HELIUM_ASSERT( !rhs.IsAbsolute() );
    return rhs.GetAbsolutePath( *this );
}