- scene::Node &createEntity(EntityClass *eclass)
- {
- return node_for_eclass(eclass);
- }
-
- void setKeyValueChangedFunc(KeyValueChangedFunc func)
- {
- EntityKeyValues::setKeyValueChangedFunc(func);
- }
-
- void setCounter(Counter *counter)
- {
- EntityKeyValues::setCounter(counter);
- }
-
- void connectEntities(const scene::Path &path, const scene::Path &targetPath, int index)
- {
- Entity *e1 = ScenePath_getEntity(path);
- Entity *e2 = ScenePath_getEntity(targetPath);
-
- if (e1 == 0 || e2 == 0) {
- globalErrorStream() << "entityConnectSelected: both of the selected instances must be an entity\n";
- return;
- }
-
- if (e1 == e2) {
- globalErrorStream()
- << "entityConnectSelected: the selected instances must not both be from the same entity\n";
- return;
- }
-
-
- UndoableCommand undo("entityConnectSelected");
-
- if (g_gameType == eGameTypeDoom3) {
- StringOutputStream key(16);
- if (index >= 0) {
- key << "target";
- if (index != 0) {
- key << index;
- }
- e1->setKeyValue(key.c_str(), e2->getKeyValue("name"));
- key.clear();
- } else {
- for (unsigned int i = 0;; ++i) {
- key << "target";
- if (i != 0) {
- key << i;
- }
- const char *value = e1->getKeyValue(key.c_str());
- if (string_empty(value)) {
- e1->setKeyValue(key.c_str(), e2->getKeyValue("name"));
- break;
- }
- key.clear();
- }
- }
- } else {
- ConnectEntities connector(e1, e2, index);
- const char *value = e2->getKeyValue("targetname");
- if (!string_empty(value)) {
- connector.connect(value);
- } else {
- const char *type = e2->getKeyValue("classname");
- if (string_empty(type)) {
- type = "t";
- }
- StringOutputStream key(64);
- key << type << "1";
- GlobalNamespace().makeUnique(key.c_str(), ConnectEntities::ConnectCaller(connector));
- }
- }
-
- SceneChangeNotify();
- }
-
- void setLightRadii(bool lightRadii)
- {
- g_lightRadii = lightRadii;
- }
-
- bool getLightRadii() const
- {
- return g_lightRadii;
- }
-
- void setShowNames(bool showNames)
- {
- g_showNames = showNames;
- }
-
- bool getShowNames()
- {
- return g_showNames;
- }
-
- void setShowAngles(bool showAngles)
- {
- g_showAngles = showAngles;
- }
-
- bool getShowAngles()
- {
- return g_showAngles;
- }
-
- void printStatistics() const
- {
- StringPool_analyse(EntityKeyValues::getPool());
- }
+scene::Node& createEntity( EntityClass* eclass ){
+ return node_for_eclass( eclass );
+}
+void setKeyValueChangedFunc( KeyValueChangedFunc func ){
+ EntityKeyValues::setKeyValueChangedFunc( func );
+}
+void setCounter( Counter* counter ){
+ EntityKeyValues::setCounter( counter );
+}
+void connectEntities( const scene::Path& path, const scene::Path& targetPath, int index ){
+ Entity* e1 = ScenePath_getEntity( path );
+ Entity* e2 = ScenePath_getEntity( targetPath );
+
+ if ( e1 == 0 || e2 == 0 ) {
+ globalErrorStream() << "entityConnectSelected: both of the selected instances must be an entity\n";
+ return;
+ }
+
+ if ( e1 == e2 ) {
+ globalErrorStream() << "entityConnectSelected: the selected instances must not both be from the same entity\n";
+ return;
+ }
+
+
+ UndoableCommand undo( "entityConnectSelected" );
+
+ if ( g_gameType == eGameTypeDoom3 ) {
+ StringOutputStream key( 16 );
+ if ( index >= 0 ) {
+ key << "target";
+ if ( index != 0 ) {
+ key << index;
+ }
+ e1->setKeyValue( key.c_str(), e2->getKeyValue( "name" ) );
+ key.clear();
+ }
+ else
+ {
+ for ( unsigned int i = 0; ; ++i )
+ {
+ key << "target";
+ if ( i != 0 ) {
+ key << i;
+ }
+ const char* value = e1->getKeyValue( key.c_str() );
+ if ( string_empty( value ) ) {
+ e1->setKeyValue( key.c_str(), e2->getKeyValue( "name" ) );
+ break;
+ }
+ key.clear();
+ }
+ }
+ }
+ else
+ {
+ ConnectEntities connector( e1, e2, index );
+ const char* value = e2->getKeyValue( "targetname" );
+ if ( !string_empty( value ) ) {
+ connector.connect( value );
+ }
+ else
+ {
+ const char* type = e2->getKeyValue( "classname" );
+ if ( string_empty( type ) ) {
+ type = "t";
+ }
+ StringOutputStream key( 64 );
+ key << type << "1";
+ GlobalNamespace().makeUnique( key.c_str(), ConnectEntities::ConnectCaller( connector ) );
+ }
+ }
+
+ SceneChangeNotify();
+}
+void setLightRadii( bool lightRadii ){
+ g_lightRadii = lightRadii;
+}
+bool getLightRadii() const {
+ return g_lightRadii;
+}
+void setShowNames( bool showNames ){
+ g_showNames = showNames;
+}
+bool getShowNames(){
+ return g_showNames;
+}
+void setShowAngles( bool showAngles ){
+ g_showAngles = showAngles;
+}
+bool getShowAngles(){
+ return g_showAngles;
+}
+
+void printStatistics() const {
+ StringPool_analyse( EntityKeyValues::getPool() );
+}