]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/entity.cpp
Merge branch 'NateEag-master-patch-12920' into 'master'
[xonotic/netradiant.git] / radiant / entity.cpp
1 /*
2    Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3    For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5    This file is part of GtkRadiant.
6
7    GtkRadiant is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    GtkRadiant is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with GtkRadiant; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21
22 #include "entity.h"
23
24 #include "ientity.h"
25 #include "iselection.h"
26 #include "imodel.h"
27 #include "ifilesystem.h"
28 #include "iundo.h"
29 #include "editable.h"
30
31 #include "eclasslib.h"
32 #include "scenelib.h"
33 #include "os/path.h"
34 #include "os/file.h"
35 #include "stream/stringstream.h"
36 #include "stringio.h"
37
38 #include "gtkutil/filechooser.h"
39 #include "gtkmisc.h"
40 #include "select.h"
41 #include "map.h"
42 #include "preferences.h"
43 #include "preferencesystem.h"
44 #include "stringio.h"
45 #include "gtkdlgs.h"
46 #include "mainframe.h"
47 #include "qe3.h"
48 #include "commands.h"
49
50 #include "brushmanip.h"
51 #include "patchmanip.h"
52
53 #include "uilib/uilib.h"
54
55 struct entity_globals_t
56 {
57         Vector3 color_entity;
58
59         entity_globals_t() :
60                 color_entity( 0.0f, 0.0f, 0.0f ){
61         }
62 };
63
64 entity_globals_t g_entity_globals;
65
66 class EntitySetKeyValueSelected : public scene::Graph::Walker
67 {
68 const char* m_key;
69 const char* m_value;
70 public:
71 EntitySetKeyValueSelected( const char* key, const char* value )
72         : m_key( key ), m_value( value ){
73 }
74
75 bool pre( const scene::Path& path, scene::Instance& instance ) const {
76         return true;
77 }
78
79 void post( const scene::Path& path, scene::Instance& instance ) const {
80         Entity* entity = Node_getEntity( path.top() );
81         if ( entity != 0
82                  && ( instance.childSelected() || Instance_getSelectable( instance )->isSelected() ) ) {
83                 entity->setKeyValue( m_key, m_value );
84         }
85 }
86 };
87
88 class EntitySetClassnameSelected : public scene::Graph::Walker
89 {
90 const char* m_classname;
91 public:
92 EntitySetClassnameSelected( const char* classname )
93         : m_classname( classname ){
94 }
95 bool pre( const scene::Path& path, scene::Instance& instance ) const {
96         return true;
97 }
98 void post( const scene::Path& path, scene::Instance& instance ) const {
99         Entity* entity = Node_getEntity( path.top() );
100         if ( entity != 0
101                  && ( instance.childSelected() || Instance_getSelectable( instance )->isSelected() ) ) {
102                 NodeSmartReference node( GlobalEntityCreator().createEntity( GlobalEntityClassManager().findOrInsert( m_classname, node_is_group( path.top() ) ) ) );
103
104                 EntityCopyingVisitor visitor( *Node_getEntity( node ) );
105
106                 //entity->forEachKeyValue( visitor );
107
108                 NodeSmartReference child( path.top().get() );
109                 NodeSmartReference parent( path.parent().get() );
110                 //Node_getTraversable( parent )->erase( child );
111                 if ( Node_getTraversable( child ) != 0
112                          && Node_getTraversable( node ) != 0
113                          && node_is_group( node ) ) {
114                         parentBrushes( child, node );
115                 }
116                 Node_getTraversable( parent )->insert( node );
117                 /* must do this after inserting node, otherwise problem: targeted + having model + not loaded b4 new entities aren't selectable normally + rendered only while 0 0 0 is rendered */
118                 entity->forEachKeyValue( visitor );
119                 Node_getTraversable( parent )->erase( child );
120         }
121 }
122 };
123
124 void Scene_EntitySetKeyValue_Selected( const char* key, const char* value ){
125         GlobalSceneGraph().traverse( EntitySetKeyValueSelected( key, value ) );
126 }
127
128 void Scene_EntitySetClassname_Selected( const char* classname ){
129         GlobalSceneGraph().traverse( EntitySetClassnameSelected( classname ) );
130 }
131
132
133 void Entity_ungroupSelected(){
134         if ( GlobalSelectionSystem().countSelected() < 1 ) {
135                 return;
136         }
137
138         UndoableCommand undo( "ungroupSelectedEntities" );
139
140         scene::Path world_path( makeReference( GlobalSceneGraph().root() ) );
141         world_path.push( makeReference( Map_FindOrInsertWorldspawn( g_map ) ) );
142
143         scene::Instance &instance = GlobalSelectionSystem().ultimateSelected();
144         scene::Path path = instance.path();
145
146         if ( !Node_isEntity( path.top() ) ) {
147                 path.pop();
148         }
149
150         if ( Node_getEntity( path.top() ) != 0
151                  && node_is_group( path.top() ) ) {
152                 if ( world_path.top().get_pointer() != path.top().get_pointer() ) {
153                         parentBrushes( path.top(), world_path.top() );
154                         Path_deleteTop( path );
155                 }
156         }
157 }
158
159
160 class EntityFindSelected : public scene::Graph::Walker
161 {
162 public:
163 mutable const scene::Path *groupPath;
164 mutable scene::Instance *groupInstance;
165
166 EntityFindSelected() : groupPath( 0 ), groupInstance( 0 ){
167 }
168
169 bool pre( const scene::Path& path, scene::Instance& instance ) const {
170         return true;
171 }
172
173 void post( const scene::Path& path, scene::Instance& instance ) const {
174         Entity* entity = Node_getEntity( path.top() );
175         if ( entity != 0
176                  && Instance_getSelectable( instance )->isSelected()
177                  && node_is_group( path.top() )
178                  && !groupPath ) {
179                 groupPath = &path;
180                 groupInstance = &instance;
181         }
182 }
183 };
184
185 class EntityGroupSelected : public scene::Graph::Walker
186 {
187 NodeSmartReference group, worldspawn;
188 //typedef std::pair<NodeSmartReference, NodeSmartReference> DeletionPair;
189 //Stack<DeletionPair> deleteme;
190 public:
191 EntityGroupSelected( const scene::Path &p ) : group( p.top().get() ), worldspawn( Map_FindOrInsertWorldspawn( g_map ) ){
192 }
193
194 bool pre( const scene::Path& path, scene::Instance& instance ) const {
195         return true;
196 }
197
198 void post( const scene::Path& path, scene::Instance& instance ) const {
199         Selectable *selectable = Instance_getSelectable( instance );
200         if ( selectable && selectable->isSelected() ) {
201                 Entity* entity = Node_getEntity( path.top() );
202                 if ( entity == 0 && Node_isPrimitive( path.top() ) ) {
203                         NodeSmartReference child( path.top().get() );
204                         NodeSmartReference parent( path.parent().get() );
205
206                         if ( path.size() >= 3 && parent != worldspawn ) {
207                                 NodeSmartReference parentparent( path[path.size() - 3].get() );
208
209                                 Node_getTraversable( parent )->erase( child );
210                                 Node_getTraversable( group )->insert( child );
211
212                                 if ( Node_getTraversable( parent )->empty() ) {
213                                         //deleteme.push(DeletionPair(parentparent, parent));
214                                         Node_getTraversable( parentparent )->erase( parent );
215                                 }
216                         }
217                         else
218                         {
219                                 Node_getTraversable( parent )->erase( child );
220                                 Node_getTraversable( group )->insert( child );
221                         }
222                 }
223         }
224 }
225 };
226
227 void Entity_groupSelected(){
228         if ( GlobalSelectionSystem().countSelected() < 1 ) {
229                 return;
230         }
231
232         UndoableCommand undo( "groupSelectedEntities" );
233
234         scene::Path world_path( makeReference( GlobalSceneGraph().root() ) );
235         world_path.push( makeReference( Map_FindOrInsertWorldspawn( g_map ) ) );
236
237         EntityFindSelected fse;
238         GlobalSceneGraph().traverse( fse );
239         if ( fse.groupPath ) {
240                 GlobalSceneGraph().traverse( EntityGroupSelected( *fse.groupPath ) );
241         }
242         else
243         {
244                 GlobalSceneGraph().traverse( EntityGroupSelected( world_path ) );
245         }
246 }
247
248
249 void Entity_connectSelected(){
250         if ( GlobalSelectionSystem().countSelected() == 2 ) {
251                 GlobalEntityCreator().connectEntities(
252                         GlobalSelectionSystem().penultimateSelected().path(),
253                         GlobalSelectionSystem().ultimateSelected().path(),
254                         0
255                         );
256         }
257         else
258         {
259                 globalErrorStream() << "entityConnectSelected: exactly two instances must be selected\n";
260         }
261 }
262
263 void Entity_killconnectSelected(){
264         if ( GlobalSelectionSystem().countSelected() == 2 ) {
265                 GlobalEntityCreator().connectEntities(
266                         GlobalSelectionSystem().penultimateSelected().path(),
267                         GlobalSelectionSystem().ultimateSelected().path(),
268                         1
269                         );
270         }
271         else
272         {
273                 globalErrorStream() << "entityKillConnectSelected: exactly two instances must be selected\n";
274         }
275 }
276
277 AABB Doom3Light_getBounds( const AABB& workzone ){
278         AABB aabb( workzone );
279
280         Vector3 defaultRadius( 300, 300, 300 );
281         if ( !string_parse_vector3( EntityClass_valueForKey( *GlobalEntityClassManager().findOrInsert( "light", false ), "light_radius" ), defaultRadius ) ) {
282                 globalErrorStream() << "Doom3Light_getBounds: failed to parse default light radius\n";
283         }
284
285         if ( aabb.extents[0] == 0 ) {
286                 aabb.extents[0] = defaultRadius[0];
287         }
288         if ( aabb.extents[1] == 0 ) {
289                 aabb.extents[1] = defaultRadius[1];
290         }
291         if ( aabb.extents[2] == 0 ) {
292                 aabb.extents[2] = defaultRadius[2];
293         }
294
295         if ( aabb_valid( aabb ) ) {
296                 return aabb;
297         }
298         return AABB( Vector3( 0, 0, 0 ), Vector3( 64, 64, 64 ) );
299 }
300
301 int g_iLastLightIntensity;
302
303 void Entity_createFromSelection( const char* name, const Vector3& origin ){
304 #if 0
305         if ( string_equal_nocase( name, "worldspawn" ) ) {
306                 ui::alert( MainFrame_getWindow( ), "Can't create an entity with worldspawn.", "info" );
307                 return;
308         }
309 #endif
310
311         EntityClass* entityClass = GlobalEntityClassManager().findOrInsert( name, true );
312
313         bool isModel = ( string_compare_nocase_n( name, "misc_", 5 ) == 0 && string_equal_nocase( name + string_length( name ) - 5, "model" ) ) // misc_*model (also misc_model)
314                                    || string_equal_nocase( name, "model_static" )
315                                    || ( GlobalSelectionSystem().countSelected() == 0 && string_equal_nocase( name, "func_static" ) && g_pGameDescription->mGameType == "doom3" );
316
317         bool brushesSelected = Scene_countSelectedBrushes( GlobalSceneGraph() ) != 0;
318
319         //is important to have retexturing here; if doing in the end, undo doesn't succeed;
320         if ( string_compare_nocase_n( name, "trigger_", 8 ) == 0 && brushesSelected ){
321                 const char* shader = g_pGameDescription->getKeyValue( "shader_trigger" );
322                 if ( shader && *shader ){
323                         Scene_PatchSetShader_Selected( GlobalSceneGraph(), shader );
324                         Scene_BrushSetShader_Selected( GlobalSceneGraph(), shader );
325                 }
326                 else{
327                         Scene_PatchSetShader_Selected( GlobalSceneGraph(), "textures/common/trigger" );
328                         Scene_BrushSetShader_Selected( GlobalSceneGraph(), "textures/common/trigger" );
329                 }
330         }
331
332         if ( !( entityClass->fixedsize || isModel ) && !brushesSelected ) {
333                 globalErrorStream() << "failed to create a group entity - no brushes are selected\n";
334                 return;
335         }
336
337         AABB workzone( aabb_for_minmax( Select_getWorkZone().d_work_min, Select_getWorkZone().d_work_max ) );
338
339
340         NodeSmartReference node( GlobalEntityCreator().createEntity( entityClass ) );
341
342         Node_getTraversable( GlobalSceneGraph().root() )->insert( node );
343
344         scene::Path entitypath( makeReference( GlobalSceneGraph().root() ) );
345         entitypath.push( makeReference( node.get() ) );
346         scene::Instance& instance = findInstance( entitypath );
347
348         if ( entityClass->fixedsize || ( isModel && !brushesSelected ) ) {
349                 Select_Delete();
350
351                 Transformable* transform = Instance_getTransformable( instance );
352                 if ( transform != 0 ) {
353                         transform->setType( TRANSFORM_PRIMITIVE );
354                         transform->setTranslation( origin );
355                         transform->freezeTransform();
356                 }
357
358                 GlobalSelectionSystem().setSelectedAll( false );
359
360                 Instance_setSelected( instance, true );
361         }
362         else
363         {
364                 if ( g_pGameDescription->mGameType == "doom3" ) {
365                         Node_getEntity( node )->setKeyValue( "model", Node_getEntity( node )->getKeyValue( "name" ) );
366                 }
367
368                 Scene_parentSelectedBrushesToEntity( GlobalSceneGraph(), node );
369                 Scene_forEachChildSelectable( SelectableSetSelected( true ), instance.path() );
370         }
371
372         // tweaking: when right clic dropping a light entity, ask for light value in a custom dialog box
373         // see SF bug 105383
374
375         if ( g_pGameDescription->mGameType == "hl" ) {
376                 // FIXME - Hydra: really we need a combined light AND color dialog for halflife.
377                 if ( string_equal_nocase( name, "light" )
378                          || string_equal_nocase( name, "light_environment" )
379                          || string_equal_nocase( name, "light_spot" ) ) {
380                         int intensity = g_iLastLightIntensity;
381
382                         if ( DoLightIntensityDlg( &intensity ) == eIDOK ) {
383                                 g_iLastLightIntensity = intensity;
384                                 char buf[30];
385                                 sprintf( buf, "255 255 255 %d", intensity );
386                                 Node_getEntity( node )->setKeyValue( "_light", buf );
387                         }
388                 }
389         }
390         else if ( string_equal_nocase( name, "light" ) ) {
391                 if ( g_pGameDescription->mGameType != "doom3" ) {
392                         int intensity = g_iLastLightIntensity;
393
394                         if ( DoLightIntensityDlg( &intensity ) == eIDOK ) {
395                                 g_iLastLightIntensity = intensity;
396                                 char buf[10];
397                                 sprintf( buf, "%d", intensity );
398                                 Node_getEntity( node )->setKeyValue( "light", buf );
399                         }
400                 }
401                 else if ( brushesSelected ) { // use workzone to set light position/size for doom3 lights, if there are brushes selected
402                         AABB bounds( Doom3Light_getBounds( workzone ) );
403                         StringOutputStream key( 64 );
404                         key << bounds.origin[0] << " " << bounds.origin[1] << " " << bounds.origin[2];
405                         Node_getEntity( node )->setKeyValue( "origin", key.c_str() );
406                         key.clear();
407                         key << bounds.extents[0] << " " << bounds.extents[1] << " " << bounds.extents[2];
408                         Node_getEntity( node )->setKeyValue( "light_radius", key.c_str() );
409                 }
410         }
411
412         if ( isModel ) {
413                 const char* model = misc_model_dialog(MainFrame_getWindow());
414                 if ( model != 0 ) {
415                         Node_getEntity( node )->setKeyValue( "model", model );
416                 }
417         }
418 }
419
420 #if 0
421 bool DoNormalisedColor( Vector3& color ){
422         if ( !color_dialog( MainFrame_getWindow( ), color ) ) {
423                 return false;
424         }
425         /*
426         ** scale colors so that at least one component is at 1.0F
427         */
428
429         float largest = 0.0F;
430
431         if ( color[0] > largest ) {
432                 largest = color[0];
433         }
434         if ( color[1] > largest ) {
435                 largest = color[1];
436         }
437         if ( color[2] > largest ) {
438                 largest = color[2];
439         }
440
441         if ( largest == 0.0F ) {
442                 color[0] = 1.0F;
443                 color[1] = 1.0F;
444                 color[2] = 1.0F;
445         }
446         else
447         {
448                 float scaler = 1.0F / largest;
449
450                 color[0] *= scaler;
451                 color[1] *= scaler;
452                 color[2] *= scaler;
453         }
454
455         return true;
456 }
457 #endif
458
459 void NormalizeColor( Vector3& color ){
460         // scale colors so that at least one component is at 1.0F
461
462         float largest = 0.0F;
463
464         if ( color[0] > largest ) {
465                 largest = color[0];
466         }
467         if ( color[1] > largest ) {
468                 largest = color[1];
469         }
470         if ( color[2] > largest ) {
471                 largest = color[2];
472         }
473
474         if ( largest == 0.0F ) {
475                 color[0] = 1.0F;
476                 color[1] = 1.0F;
477                 color[2] = 1.0F;
478         }
479         else
480         {
481                 float scaler = 1.0F / largest;
482
483                 color[0] *= scaler;
484                 color[1] *= scaler;
485                 color[2] *= scaler;
486         }
487 }
488
489 void Entity_normalizeColor(){
490         if ( GlobalSelectionSystem().countSelected() != 0 ) {
491                 const scene::Path& path = GlobalSelectionSystem().ultimateSelected().path();
492                 Entity* entity = Node_getEntity( path.top() );
493
494                 if( entity == 0 && path.size() == 3 ){
495                         entity = Node_getEntity( path.parent() );
496                 }
497
498                 if ( entity != 0 ) {
499                         const char* strColor = entity->getKeyValue( "_color" );
500                         if ( !string_empty( strColor ) ) {
501                                 Vector3 rgb;
502                                 if ( string_parse_vector3( strColor, rgb ) ) {
503                                         g_entity_globals.color_entity = rgb;
504                                         NormalizeColor( g_entity_globals.color_entity );
505
506                                         char buffer[128];
507                                         sprintf( buffer, "%g %g %g", g_entity_globals.color_entity[0],
508                                                          g_entity_globals.color_entity[1],
509                                                          g_entity_globals.color_entity[2] );
510
511                                         StringOutputStream command( 256 );
512                                         command << "entityNormalizeColour " << buffer;
513                                         UndoableCommand undo( command.c_str() );
514                                         Scene_EntitySetKeyValue_Selected( "_color", buffer );
515                                 }
516                         }
517                 }
518         }
519 }
520
521 void Entity_setColour(){
522         if ( GlobalSelectionSystem().countSelected() != 0 ) {
523                 const scene::Path& path = GlobalSelectionSystem().ultimateSelected().path();
524                 Entity* entity = Node_getEntity( path.top() );
525
526                 if( entity == 0 && path.size() == 3 ){
527                         entity = Node_getEntity( path.parent() );
528                 }
529
530                 if ( entity != 0 ) {
531                         const char* strColor = entity->getKeyValue( "_color" );
532                         if ( !string_empty( strColor ) ) {
533                                 Vector3 rgb;
534                                 if ( string_parse_vector3( strColor, rgb ) ) {
535                                         g_entity_globals.color_entity = rgb;
536                                 }
537                         }
538                         if ( color_dialog( MainFrame_getWindow(), g_entity_globals.color_entity ) ) {
539                                 char buffer[128];
540                                 sprintf( buffer, "%g %g %g", g_entity_globals.color_entity[0],
541                                                  g_entity_globals.color_entity[1],
542                                                  g_entity_globals.color_entity[2] );
543
544                                 StringOutputStream command( 256 );
545                                 command << "entitySetColour " << buffer;
546                                 UndoableCommand undo( command.c_str() );
547                                 Scene_EntitySetKeyValue_Selected( "_color", buffer );
548                         }
549                 }
550         }
551 }
552
553 CopiedString g_strLastModelFolder = "";
554
555 const char *getLastModelFolderPath(){
556         if ( g_strLastModelFolder.empty() ) {
557                 GlobalPreferenceSystem().registerPreference( "LastModelFolder", make_property_string( g_strLastModelFolder ) );
558                 if ( g_strLastModelFolder.empty() ) {
559                         StringOutputStream buffer( 1024 );
560                         buffer << g_qeglobals.m_userGamePath.c_str() << "models/";
561                         if ( !file_readable( buffer.c_str() ) ) {
562                                 // just go to fsmain
563                                 buffer.clear();
564                                 buffer << g_qeglobals.m_userGamePath.c_str() << "/";
565                         }
566                         g_strLastModelFolder = buffer.c_str();
567                 }
568         }
569         return g_strLastModelFolder.c_str();
570 }
571
572 const char *misc_model_dialog( ui::Widget parent ){
573         const char *filename = parent.file_dialog( TRUE, "Choose Model", getLastModelFolderPath(), ModelLoader::Name() );
574
575         if ( filename != NULL ) {
576                 g_strLastModelFolder = g_path_get_dirname( filename );
577                 // use VFS to get the correct relative path
578                 const char *relative = path_make_relative( filename, GlobalFileSystem().findRoot( filename ) );
579                 if ( relative == filename ) {
580                         globalOutputStream() << "WARNING: could not extract the relative path, using full path instead\n";
581                 }
582                 return relative;
583         }
584         return 0;
585 }
586 /*
587 struct LightRadii {
588         static void Export(const EntityCreator &self, const Callback<void(bool)> &returnz) {
589                 returnz(self.getLightRadii());
590         }
591
592         static void Import(EntityCreator &self, bool value) {
593                 self.setLightRadii(value);
594         }
595 };
596
597 void Entity_constructPreferences( PreferencesPage& page ){
598         page.appendCheckBox(
599                         "Show", "Light Radii",
600                         make_property<LightRadii>(GlobalEntityCreator())
601         );
602 }
603 void Entity_constructPage( PreferenceGroup& group ){
604         PreferencesPage page( group.createPage( "Entities", "Entity Display Preferences" ) );
605         Entity_constructPreferences( page );
606 }
607
608 void Entity_registerPreferencesPage(){
609         PreferencesDialog_addDisplayPage( makeCallbackF(Entity_constructPage) );
610 }
611 */
612
613 void ShowLightRadiiToggle(){
614         GlobalEntityCreator().setLightRadii( !GlobalEntityCreator().getLightRadii() );
615         UpdateAllWindows();
616 }
617 typedef FreeCaller<void(), ShowLightRadiiToggle> ShowLightRadiiToggleCaller;
618 void ShowLightRadiiExport( const Callback<void(bool)> & importer ){
619         GlobalEntityCreator().getLightRadii();
620 }
621 typedef FreeCaller<void(const Callback<void(bool)> &), ShowLightRadiiExport> ShowLightRadiiExportCaller;
622
623 ShowLightRadiiExportCaller g_show_lightradii_caller;
624 Callback<void(const Callback<void(bool)> &)> g_show_lightradii_callback( g_show_lightradii_caller );
625 ToggleItem g_show_lightradii( g_show_lightradii_callback );
626
627 void Entity_constructMenu( ui::Menu menu ){
628         create_menu_item_with_mnemonic( menu, "_Regroup", "GroupSelection" );
629         create_menu_item_with_mnemonic( menu, "_Ungroup", "UngroupSelection" );
630         create_menu_item_with_mnemonic( menu, "_Connect", "ConnectSelection" );
631         if ( g_pGameDescription->mGameType == "nexuiz" ) {
632                 create_menu_item_with_mnemonic( menu, "_KillConnect", "KillConnectSelection" );
633         }
634         create_menu_item_with_mnemonic( menu, "_Select Color...", "EntityColor" );
635         create_menu_item_with_mnemonic( menu, "_Normalize Color", "NormalizeColor" );
636 }
637
638
639 void Entity_Construct(){
640         GlobalCommands_insert( "EntityColor", makeCallbackF(Entity_setColour), Accelerator( 'K' ) );
641         GlobalCommands_insert( "NormalizeColor", makeCallbackF(Entity_normalizeColor) );
642         GlobalCommands_insert( "ConnectSelection", makeCallbackF(Entity_connectSelected), Accelerator( 'K', (GdkModifierType)GDK_CONTROL_MASK ) );
643         GlobalCommands_insert( "KillConnectSelection", makeCallbackF(Entity_killconnectSelected), Accelerator( 'K', (GdkModifierType)( GDK_SHIFT_MASK ) ) );
644         GlobalCommands_insert( "GroupSelection", makeCallbackF(Entity_groupSelected) );
645         GlobalCommands_insert( "UngroupSelection", makeCallbackF(Entity_ungroupSelected) );
646
647         GlobalToggles_insert( "ShowLightRadiuses", makeCallbackF( ShowLightRadiiToggle ), ToggleItem::AddCallbackCaller( g_show_lightradii ) );
648
649         GlobalPreferenceSystem().registerPreference( "SI_Colors5", make_property_string( g_entity_globals.color_entity ) );
650         GlobalPreferenceSystem().registerPreference( "LastLightIntensity", make_property_string( g_iLastLightIntensity ) );
651
652 //      Entity_registerPreferencesPage();
653 }
654
655 void Entity_Destroy(){
656 }