- EntityClass* entityClass = GlobalEntityClassManager().findOrInsert(name, true);
-
- bool isModel = (string_compare_nocase_n(name, "misc_", 5) == 0 && string_equal_nocase(name + string_length(name) - 5, "model")) // misc_*model (also misc_model)
- || string_equal_nocase(name, "model_static")
- || (GlobalSelectionSystem().countSelected() == 0 && string_equal_nocase(name, "func_static"));
-
- bool brushesSelected = Scene_countSelectedBrushes(GlobalSceneGraph()) != 0;
-
- if(!(entityClass->fixedsize || isModel) && !brushesSelected)
- {
- globalErrorStream() << "failed to create a group entity - no brushes are selected\n";
- return;
- }
-
- AABB workzone(aabb_for_minmax(Select_getWorkZone().d_work_min, Select_getWorkZone().d_work_max));
-
-
- NodeSmartReference node(GlobalEntityCreator().createEntity(entityClass));
-
- Node_getTraversable(GlobalSceneGraph().root())->insert(node);
-
- scene::Path entitypath(makeReference(GlobalSceneGraph().root()));
- entitypath.push(makeReference(node.get()));
- scene::Instance& instance = findInstance(entitypath);
-
- if(entityClass->fixedsize || (isModel && !brushesSelected))
- {
- Select_Delete();
-
- Transformable* transform = Instance_getTransformable(instance);
- if(transform != 0)
- {
- transform->setType(TRANSFORM_PRIMITIVE);
- transform->setTranslation(origin);
- transform->freezeTransform();
- }
-
- GlobalSelectionSystem().setSelectedAll(false);
-
- Instance_setSelected(instance, true);
- }
- else
- {
- if (g_pGameDescription->mGameType == "doom3")
- {
- Node_getEntity(node)->setKeyValue("model", Node_getEntity(node)->getKeyValue("name"));
- }
-
- Scene_parentSelectedBrushesToEntity(GlobalSceneGraph(), node);
- Scene_forEachChildSelectable(SelectableSetSelected(true), instance.path());
- }
-
- // tweaking: when right clic dropping a light entity, ask for light value in a custom dialog box
- // see SF bug 105383
-
- if (g_pGameDescription->mGameType == "hl")
- {
- // FIXME - Hydra: really we need a combined light AND color dialog for halflife.
- if (string_equal_nocase(name, "light")
- || string_equal_nocase(name, "light_environment")
- || string_equal_nocase(name, "light_spot"))
- {
- int intensity = g_iLastLightIntensity;
-
- if (DoLightIntensityDlg (&intensity) == eIDOK)
- {
- g_iLastLightIntensity = intensity;
- char buf[30];
- sprintf( buf, "255 255 255 %d", intensity );
- Node_getEntity(node)->setKeyValue("_light", buf);
- }
- }
- }
- else if(string_equal_nocase(name, "light"))
- {
- if(g_pGameDescription->mGameType != "doom3")
- {
- int intensity = g_iLastLightIntensity;
-
- if (DoLightIntensityDlg (&intensity) == eIDOK)
- {
- g_iLastLightIntensity = intensity;
- char buf[10];
- sprintf( buf, "%d", intensity );
- Node_getEntity(node)->setKeyValue("light", buf);
- }
- }
- else if(brushesSelected) // use workzone to set light position/size for doom3 lights, if there are brushes selected
- {
- AABB bounds(Doom3Light_getBounds(workzone));
- StringOutputStream key(64);
- key << bounds.origin[0] << " " << bounds.origin[1] << " " << bounds.origin[2];
- Node_getEntity(node)->setKeyValue("origin", key.c_str());
- key.clear();
- key << bounds.extents[0] << " " << bounds.extents[1] << " " << bounds.extents[2];
- Node_getEntity(node)->setKeyValue("light_radius", key.c_str());
- }
- }
-
- if(isModel)
- {
- const char* model = misc_model_dialog(GTK_WIDGET(MainFrame_getWindow()));
- if(model != 0)
- {
- Node_getEntity(node)->setKeyValue("model", model);
- }
- }
+ EntityClass* entityClass = GlobalEntityClassManager().findOrInsert( name, true );
+
+ bool isModel = ( string_compare_nocase_n( name, "misc_", 5 ) == 0 && string_equal_nocase( name + string_length( name ) - 5, "model" ) ) // misc_*model (also misc_model)
+ || string_equal_nocase( name, "model_static" )
+ || ( GlobalSelectionSystem().countSelected() == 0 && string_equal_nocase( name, "func_static" ) && g_pGameDescription->mGameType == "doom3" );
+
+ bool brushesSelected = Scene_countSelectedBrushes( GlobalSceneGraph() ) != 0;
+
+ if ( !( entityClass->fixedsize || isModel ) && !brushesSelected ) {
+ globalErrorStream() << "failed to create a group entity - no brushes are selected\n";
+ return;
+ }
+
+ AABB workzone( aabb_for_minmax( Select_getWorkZone().d_work_min, Select_getWorkZone().d_work_max ) );
+
+
+ NodeSmartReference node( GlobalEntityCreator().createEntity( entityClass ) );
+
+ Node_getTraversable( GlobalSceneGraph().root() )->insert( node );
+
+ scene::Path entitypath( makeReference( GlobalSceneGraph().root() ) );
+ entitypath.push( makeReference( node.get() ) );
+ scene::Instance& instance = findInstance( entitypath );
+
+ if ( entityClass->fixedsize || ( isModel && !brushesSelected ) ) {
+ Select_Delete();
+
+ Transformable* transform = Instance_getTransformable( instance );
+ if ( transform != 0 ) {
+ transform->setType( TRANSFORM_PRIMITIVE );
+ transform->setTranslation( origin );
+ transform->freezeTransform();
+ }
+
+ GlobalSelectionSystem().setSelectedAll( false );
+
+ Instance_setSelected( instance, true );
+ }
+ else
+ {
+ if ( g_pGameDescription->mGameType == "doom3" ) {
+ Node_getEntity( node )->setKeyValue( "model", Node_getEntity( node )->getKeyValue( "name" ) );
+ }
+
+ Scene_parentSelectedBrushesToEntity( GlobalSceneGraph(), node );
+ Scene_forEachChildSelectable( SelectableSetSelected( true ), instance.path() );
+ }
+
+ // tweaking: when right clic dropping a light entity, ask for light value in a custom dialog box
+ // see SF bug 105383
+
+ if ( g_pGameDescription->mGameType == "hl" ) {
+ // FIXME - Hydra: really we need a combined light AND color dialog for halflife.
+ if ( string_equal_nocase( name, "light" )
+ || string_equal_nocase( name, "light_environment" )
+ || string_equal_nocase( name, "light_spot" ) ) {
+ int intensity = g_iLastLightIntensity;
+
+ if ( DoLightIntensityDlg( &intensity ) == eIDOK ) {
+ g_iLastLightIntensity = intensity;
+ char buf[30];
+ sprintf( buf, "255 255 255 %d", intensity );
+ Node_getEntity( node )->setKeyValue( "_light", buf );
+ }
+ }
+ }
+ else if ( string_equal_nocase( name, "light" ) ) {
+ if ( g_pGameDescription->mGameType != "doom3" ) {
+ int intensity = g_iLastLightIntensity;
+
+ if ( DoLightIntensityDlg( &intensity ) == eIDOK ) {
+ g_iLastLightIntensity = intensity;
+ char buf[10];
+ sprintf( buf, "%d", intensity );
+ Node_getEntity( node )->setKeyValue( "light", buf );
+ }
+ }
+ else if ( brushesSelected ) { // use workzone to set light position/size for doom3 lights, if there are brushes selected
+ AABB bounds( Doom3Light_getBounds( workzone ) );
+ StringOutputStream key( 64 );
+ key << bounds.origin[0] << " " << bounds.origin[1] << " " << bounds.origin[2];
+ Node_getEntity( node )->setKeyValue( "origin", key.c_str() );
+ key.clear();
+ key << bounds.extents[0] << " " << bounds.extents[1] << " " << bounds.extents[2];
+ Node_getEntity( node )->setKeyValue( "light_radius", key.c_str() );
+ }
+ }
+
+ if ( isModel ) {
+ const char* model = misc_model_dialog(MainFrame_getWindow());
+ if ( model != 0 ) {
+ Node_getEntity( node )->setKeyValue( "model", model );
+ }
+ }
+
+ if ( string_compare_nocase_n( name, "trigger_", 8 ) == 0 && brushesSelected ){
+ const char* shader = g_pGameDescription->getKeyValue( "shader_trigger" );
+ if ( shader && *shader ){
+ Scene_PatchSetShader_Selected( GlobalSceneGraph(), shader );
+ Scene_BrushSetShader_Selected( GlobalSceneGraph(), shader );
+ }
+ else{
+ Scene_PatchSetShader_Selected( GlobalSceneGraph(), "textures/common/trigger" );
+ Scene_BrushSetShader_Selected( GlobalSceneGraph(), "textures/common/trigger" );
+ }
+ }