void CollectionsPanel::UpdateCollections() { m_CollectionToItemIDs.clear(); PrePopulateTreeCtrl( m_TempCollectionsTreeCtrl ); PrePopulateTreeCtrl( m_MyCollectionsTreeCtrl ); { u32 tempItemsAdded = 0; u32 myItemsAdded = 0; for ( M_AssetCollections::const_iterator itr = m_CollectionManager->GetCollections().begin(), end = m_CollectionManager->GetCollections().end(); itr != end; ++itr ) { AssetCollection* collection = itr->second; HELIUM_ASSERT( collection ); if ( !collection ) continue; int iconIndex = m_ContainerImageIndex; if ( collection->GetType() == Reflect::GetType< Editor::AssetCollection >() ) { iconIndex = m_ContainerImageIndex; } SortTreeCtrl* treeCtrl = NULL; if ( collection->IsTemporary() ) { treeCtrl = m_TempCollectionsTreeCtrl; ++tempItemsAdded; } else { treeCtrl = m_MyCollectionsTreeCtrl; ++myItemsAdded; } wxTreeItemId itemID = treeCtrl->AppendItem( treeCtrl->GetRootItem(), collection->GetDisplayName(), iconIndex, -1, new AssetCollectionItemData( collection ) ); m_CollectionToItemIDs.insert( M_CollectionToItemID::value_type( collection->GetPath().Hash(), itemID ) ); } m_TempCollectionsTreeCtrl->Enable( tempItemsAdded > 0 ); if ( tempItemsAdded < 1 ) { wxTreeItemId itemID = m_TempCollectionsTreeCtrl->AppendItem( m_TempCollectionsTreeCtrl->GetRootItem(), TXT( "None Available" ) ); } } PostPopulateTreeCtrl( m_MyCollectionsTreeCtrl ); PostPopulateTreeCtrl( m_TempCollectionsTreeCtrl ); }
void CollectionsPanel::OnSaveCollection( wxCommandEvent& event ) { SortTreeCtrl* treeCtrl = m_MyCollectionsTreeCtrl; wxTreeItemId rootID = treeCtrl->GetRootItem(); wxTreeItemId item = treeCtrl->GetSelection(); if( !item || item == rootID ) { return; } AssetCollectionItemData* baseData = GetItemData( treeCtrl, item ); if ( !baseData ) { return; } AssetCollection* collection = baseData->GetCollection<AssetCollection>(); if ( collection ) { tstring defaultDir( collection->GetPath().Directory() ); tstring defaultFile( collection->GetPath().Filename() ); Helium::FileDialog browserDlg( this, VaultMenu::Label( ID_SaveCollection ), defaultDir.c_str(), defaultFile.c_str(), TXT( "" ), Helium::FileDialogStyles::DefaultSave | Helium::FileDialogStyles::ShowAllFilesFilter | Helium::FileDialogStyles::ExportFile ); std::vector< tstring > filters; AssetCollection::GetFileFilters( filters ); browserDlg.AddFilters( filters ); if ( browserDlg.ShowModal() == wxID_OK ) { m_CollectionManager->SaveCollection( collection, (const wxChar*)browserDlg.GetPath().c_str() ); } } }
void CollectionsPanel::OnNewCollection( wxCommandEvent& event ) { int eventID = event.GetId(); AssetCollection* collection = NULL; switch ( eventID ) { default: collection = NULL; break; case ID_NewCollection: collection = NewCollection( m_CollectionManager, Reflect::GetType< Editor::AssetCollection >() ); break; } M_CollectionToItemID::iterator findItem = m_CollectionToItemIDs.find( collection->GetPath().Hash() ); if ( findItem != m_CollectionToItemIDs.end() && findItem->second.IsOk() ) { m_MyCollectionsTreeCtrl->EditLabel( findItem->second ); } }