bool Material::onAdd() { if (Parent::onAdd() == false) return false; mCubemapData = dynamic_cast<CubemapData*>(Sim::findObject( mCubemapName ) ); if( mTranslucentBlendOp >= NumBlendTypes || mTranslucentBlendOp < 0 ) { Con::errorf( "Invalid blend op in material: %s", getName() ); mTranslucentBlendOp = LerpAlpha; } SimSet *matSet = MATMGR->getMaterialSet(); if( matSet ) matSet->addObject( (SimObject*)this ); // save the current script path for texture lookup later const String scriptFile = Con::getVariable("$Con::File"); // current script file - local materials.cs String::SizeType slash = scriptFile.find( '/', scriptFile.length(), String::Right ); if ( slash != String::NPos ) mPath = scriptFile.substr( 0, slash + 1 ); _mapMaterial(); return true; }
bool SimTreeView::handleItemDroppedOnItem( HTREEITEM hTarget, HTREEITEM hDropItem ) { bool removeFromSource=false; lockManager(); HTREEITEM hParent = getParent( hTarget ); SimSet *pTarget = (SimSet*)getObject( hParent ); SimObject *obj = getObject(hDragItem); SimObject *pParent = getObject( getParent(hDropItem) ); if ( pTarget != obj ) { state.set(STV_MODIFIED); if ( pTarget->find(pTarget->begin(), pTarget->end(), obj) != pTarget->end() ) { if ( pTarget->reOrder( obj, getObject(hTarget) ) ) refresh( hParent ); } else { if ( !dynamic_cast<SimGroup*>(pTarget) ) { if ( dynamic_cast<SimGroup*>(pParent) ) removeFromSource = false; // Group->Set, copy else if ( (GetKeyState( VK_SHIFT ) & 0x80000000) == 0 ) removeFromSource = true; // Set->Set, but pressing shift key, copy else removeFromSource = true; // Set->Set, copying set by menu } else if ( !dynamic_cast<SimGroup*>(pParent) ) { unlockManager(); return false; // set->Group is not allowed } else { state.clear(GWTV_COPYING); // Group->Group, moving removeFromSource = true; } pTarget->addObject(obj); pTarget->reOrder( obj, getObject(hTarget) ); WinParent::handleItemDroppedOnItem( hTarget, hDropItem ); } } unlockManager(); return removeFromSource; // don't modify list after return }
bool tripod::onAdd() { if (!ObjParent::onAdd()) return false; // Post by sending an event addToSet(SimTimerSetId); SimSet *grp; grp = (SimSet*)manager->findObject( SimCameraSetId ); if ( grp ) grp->addObject( this ); setEventMap(); return true; }
SimSet* SimSet::clone() { // Clone the set object. SimObject* object = Parent::clone(); SimSet* set = dynamic_cast< SimSet* >( object ); if( !set ) { object->deleteObject(); return NULL; } // Add all object in the set. for( iterator iter = begin(); iter != end(); ++ iter ) set->addObject( *iter ); return set; }
bool TerrainMaterial::onAdd() { if ( !Parent::onAdd() ) return false; SimSet *set = Sim::getTerrainMaterialSet(); // Make sure we have an internal name set. if ( !mInternalName || !mInternalName[0] ) Con::warnf( "TerrainMaterial::onAdd() - No internal name set!" ); else { SimObject *object = set->findObjectByInternalName( mInternalName ); if ( object ) Con::warnf( "TerrainMaterial::onAdd() - Internal name collision; '%s' already exists!", mInternalName ); } set->addObject( this ); return true; }
void SimTreeView::onCommand( int id, HWND hwndCtl, UINT codeNotify ) { hwndCtl, codeNotify; SimObject *obj; SimSet *prnt; lockManager(); switch( id ) { case IDM_EXIT: destroyWindow(); break; case IDM_CUT: if ( (obj = getSelectedObject()) != NULL ) { // persist selected object obj->fileStore( "temp\\clip.tmp" ); // remove it from parent obj->deleteObject(); delItem( getSelection() ); state.set(STV_MODIFIED); } break; case IDM_COPY: if ( (obj = getSelectedObject()) != NULL ) obj->fileStore( "temp\\clip.tmp" ); break; case IDM_PASTE: { // unpersist object to get a duplicate Persistent::Base::Error err; obj = (SimObject*)Persistent::Base::fileLoad( "temp\\clip.tmp", &err ); if ( err != Ok ) return; // add to simTree HTREEITEM hParent = getSelection(); if ( !isItemFolder(hParent) ) hParent = getParent( hParent ); prnt = (SimSet*)getObject( hParent ); prnt->getManager()->addObject( obj ); prnt->addObject(obj); HTREEITEM hItem = addSet( obj, hParent ); selectItem( hItem ); state.set(STV_MODIFIED); } break; case IDM_DELETE: obj = getSelectedObject(); if ( obj ) { obj->deleteObject(); delItem( getSelection() ); state.set(STV_MODIFIED); } break; case IDM_REMOVE: obj = getSelectedObject(); if ( obj ) { prnt = getSelectedParent(); prnt->removeObject(obj); delItem( getSelection() ); state.set(STV_MODIFIED); } break; case IDM_DUPLICATE: { obj = getSelectedObject(); // persist object to get a duplicate if ( obj->fileStore( "temp\\clip.tmp" ) != Ok ) { unlockManager(); return; } Persistent::Base::Error err; obj = (SimObject*)Persistent::Base::fileLoad( "temp\\clip.tmp", &err ); if ( err != Ok ) { unlockManager(); return; } // perhaps delete clip.tmp to clean up directory HTREEITEM hParent = getSelection(); if ( !isItemFolder(hParent) ) hParent = getParent( hParent ); prnt = (SimSet*)getObject( hParent ); prnt->getManager()->addObject( obj ); prnt->addObject( obj ); HTREEITEM hItem = addSet( obj, getParent(getSelection()) ); selectItem( hItem ); state.set(STV_MODIFIED); } break; case IDM_EDIT: inspectObject( getSelectedObject() ); state.set(STV_MODIFIED); break; case IDM_LOCK: lockObject( getSelectedObject(), true ); state.set( STV_MODIFIED ); break; case IDM_UNLOCK: lockObject( getSelectedObject(), false ); state.set( STV_MODIFIED ); break; default: if ( (id>=IDM_SCRIPT_START) && (id<=scriptMenu_IDM) ) { int scriptIndex = id-IDM_SCRIPT_START; CMDConsole::getLocked()->evaluate( script[scriptIndex], false ); } // let parent handle its default menu items WinParent::handleContextMenuItemSelection( id ); } checkMenu( hMainMenu ); unlockManager(); }