]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/entity.cpp
Merge commit '2ab47003e0b34d7ca43d4ac5b9ae18d3413a4f4c' into garux-merge
[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         if ( !( entityClass->fixedsize || isModel ) && !brushesSelected ) {
320                 globalErrorStream() << "failed to create a group entity - no brushes are selected\n";
321                 return;
322         }
323
324         AABB workzone( aabb_for_minmax( Select_getWorkZone().d_work_min, Select_getWorkZone().d_work_max ) );
325
326
327         NodeSmartReference node( GlobalEntityCreator().createEntity( entityClass ) );
328
329         Node_getTraversable( GlobalSceneGraph().root() )->insert( node );
330
331         scene::Path entitypath( makeReference( GlobalSceneGraph().root() ) );
332         entitypath.push( makeReference( node.get() ) );
333         scene::Instance& instance = findInstance( entitypath );
334
335         if ( entityClass->fixedsize || ( isModel && !brushesSelected ) ) {
336                 Select_Delete();
337
338                 Transformable* transform = Instance_getTransformable( instance );
339                 if ( transform != 0 ) {
340                         transform->setType( TRANSFORM_PRIMITIVE );
341                         transform->setTranslation( origin );
342                         transform->freezeTransform();
343                 }
344
345                 GlobalSelectionSystem().setSelectedAll( false );
346
347                 Instance_setSelected( instance, true );
348         }
349         else
350         {
351                 if ( g_pGameDescription->mGameType == "doom3" ) {
352                         Node_getEntity( node )->setKeyValue( "model", Node_getEntity( node )->getKeyValue( "name" ) );
353                 }
354
355                 Scene_parentSelectedBrushesToEntity( GlobalSceneGraph(), node );
356                 Scene_forEachChildSelectable( SelectableSetSelected( true ), instance.path() );
357         }
358
359         // tweaking: when right clic dropping a light entity, ask for light value in a custom dialog box
360         // see SF bug 105383
361
362         if ( g_pGameDescription->mGameType == "hl" ) {
363                 // FIXME - Hydra: really we need a combined light AND color dialog for halflife.
364                 if ( string_equal_nocase( name, "light" )
365                          || string_equal_nocase( name, "light_environment" )
366                          || string_equal_nocase( name, "light_spot" ) ) {
367                         int intensity = g_iLastLightIntensity;
368
369                         if ( DoLightIntensityDlg( &intensity ) == eIDOK ) {
370                                 g_iLastLightIntensity = intensity;
371                                 char buf[30];
372                                 sprintf( buf, "255 255 255 %d", intensity );
373                                 Node_getEntity( node )->setKeyValue( "_light", buf );
374                         }
375                 }
376         }
377         else if ( string_equal_nocase( name, "light" ) ) {
378                 if ( g_pGameDescription->mGameType != "doom3" ) {
379                         int intensity = g_iLastLightIntensity;
380
381                         if ( DoLightIntensityDlg( &intensity ) == eIDOK ) {
382                                 g_iLastLightIntensity = intensity;
383                                 char buf[10];
384                                 sprintf( buf, "%d", intensity );
385                                 Node_getEntity( node )->setKeyValue( "light", buf );
386                         }
387                 }
388                 else if ( brushesSelected ) { // use workzone to set light position/size for doom3 lights, if there are brushes selected
389                         AABB bounds( Doom3Light_getBounds( workzone ) );
390                         StringOutputStream key( 64 );
391                         key << bounds.origin[0] << " " << bounds.origin[1] << " " << bounds.origin[2];
392                         Node_getEntity( node )->setKeyValue( "origin", key.c_str() );
393                         key.clear();
394                         key << bounds.extents[0] << " " << bounds.extents[1] << " " << bounds.extents[2];
395                         Node_getEntity( node )->setKeyValue( "light_radius", key.c_str() );
396                 }
397         }
398
399         if ( isModel ) {
400                 const char* model = misc_model_dialog(MainFrame_getWindow());
401                 if ( model != 0 ) {
402                         Node_getEntity( node )->setKeyValue( "model", model );
403                 }
404         }
405
406         if ( string_compare_nocase_n( name, "trigger_", 8 ) == 0 && brushesSelected ){
407                 const char* shader = g_pGameDescription->getKeyValue( "shader_trigger" );
408                 if ( shader && *shader ){
409                         Scene_PatchSetShader_Selected( GlobalSceneGraph(), shader );
410                         Scene_BrushSetShader_Selected( GlobalSceneGraph(), shader );
411                 }
412                 else{
413                         Scene_PatchSetShader_Selected( GlobalSceneGraph(), "textures/common/trigger" );
414                         Scene_BrushSetShader_Selected( GlobalSceneGraph(), "textures/common/trigger" );
415                 }
416         }
417 }
418
419 #if 0
420 bool DoNormalisedColor( Vector3& color ){
421         if ( !color_dialog( MainFrame_getWindow( ), color ) ) {
422                 return false;
423         }
424         /*
425         ** scale colors so that at least one component is at 1.0F
426         */
427
428         float largest = 0.0F;
429
430         if ( color[0] > largest ) {
431                 largest = color[0];
432         }
433         if ( color[1] > largest ) {
434                 largest = color[1];
435         }
436         if ( color[2] > largest ) {
437                 largest = color[2];
438         }
439
440         if ( largest == 0.0F ) {
441                 color[0] = 1.0F;
442                 color[1] = 1.0F;
443                 color[2] = 1.0F;
444         }
445         else
446         {
447                 float scaler = 1.0F / largest;
448
449                 color[0] *= scaler;
450                 color[1] *= scaler;
451                 color[2] *= scaler;
452         }
453
454         return true;
455 }
456 #endif
457
458 void NormalizeColor( Vector3& color ){
459         // scale colors so that at least one component is at 1.0F
460
461         float largest = 0.0F;
462
463         if ( color[0] > largest ) {
464                 largest = color[0];
465         }
466         if ( color[1] > largest ) {
467                 largest = color[1];
468         }
469         if ( color[2] > largest ) {
470                 largest = color[2];
471         }
472
473         if ( largest == 0.0F ) {
474                 color[0] = 1.0F;
475                 color[1] = 1.0F;
476                 color[2] = 1.0F;
477         }
478         else
479         {
480                 float scaler = 1.0F / largest;
481
482                 color[0] *= scaler;
483                 color[1] *= scaler;
484                 color[2] *= scaler;
485         }
486 }
487
488 void Entity_normalizeColor(){
489         if ( GlobalSelectionSystem().countSelected() != 0 ) {
490                 const scene::Path& path = GlobalSelectionSystem().ultimateSelected().path();
491                 Entity* entity = Node_getEntity( path.top() );
492
493                 if( entity == 0 && path.size() == 3 ){
494                         entity = Node_getEntity( path.parent() );
495                 }
496
497                 if ( entity != 0 ) {
498                         const char* strColor = entity->getKeyValue( "_color" );
499                         if ( !string_empty( strColor ) ) {
500                                 Vector3 rgb;
501                                 if ( string_parse_vector3( strColor, rgb ) ) {
502                                         g_entity_globals.color_entity = rgb;
503                                         NormalizeColor( g_entity_globals.color_entity );
504
505                                         char buffer[128];
506                                         sprintf( buffer, "%g %g %g", g_entity_globals.color_entity[0],
507                                                          g_entity_globals.color_entity[1],
508                                                          g_entity_globals.color_entity[2] );
509
510                                         StringOutputStream command( 256 );
511                                         command << "entityNormalizeColour " << buffer;
512                                         UndoableCommand undo( command.c_str() );
513                                         Scene_EntitySetKeyValue_Selected( "_color", buffer );
514                                 }
515                         }
516                 }
517         }
518 }
519
520 void Entity_setColour(){
521         if ( GlobalSelectionSystem().countSelected() != 0 ) {
522                 const scene::Path& path = GlobalSelectionSystem().ultimateSelected().path();
523                 Entity* entity = Node_getEntity( path.top() );
524
525                 if( entity == 0 && path.size() == 3 ){
526                         entity = Node_getEntity( path.parent() );
527                 }
528
529                 if ( entity != 0 ) {
530                         const char* strColor = entity->getKeyValue( "_color" );
531                         if ( !string_empty( strColor ) ) {
532                                 Vector3 rgb;
533                                 if ( string_parse_vector3( strColor, rgb ) ) {
534                                         g_entity_globals.color_entity = rgb;
535                                 }
536                         }
537                         if ( color_dialog( MainFrame_getWindow(), g_entity_globals.color_entity ) ) {
538                                 char buffer[128];
539                                 sprintf( buffer, "%g %g %g", g_entity_globals.color_entity[0],
540                                                  g_entity_globals.color_entity[1],
541                                                  g_entity_globals.color_entity[2] );
542
543                                 StringOutputStream command( 256 );
544                                 command << "entitySetColour " << buffer;
545                                 UndoableCommand undo( command.c_str() );
546                                 Scene_EntitySetKeyValue_Selected( "_color", buffer );
547                         }
548                 }
549         }
550 }
551
552 CopiedString g_strLastModelFolder = "";
553
554 const char *getLastModelFolderPath(){
555         if ( g_strLastModelFolder.empty() ) {
556                 GlobalPreferenceSystem().registerPreference( "LastModelFolder", make_property_string( g_strLastModelFolder ) );
557                 if ( g_strLastModelFolder.empty() ) {
558                         StringOutputStream buffer( 1024 );
559                         buffer << g_qeglobals.m_userGamePath.c_str() << "models/";
560                         if ( !file_readable( buffer.c_str() ) ) {
561                                 // just go to fsmain
562                                 buffer.clear();
563                                 buffer << g_qeglobals.m_userGamePath.c_str() << "/";
564                         }
565                         g_strLastModelFolder = buffer.c_str();
566                 }
567         }
568         return g_strLastModelFolder.c_str();
569 }
570
571 const char *misc_model_dialog( ui::Widget parent ){
572         const char *filename = parent.file_dialog( TRUE, "Choose Model", getLastModelFolderPath(), ModelLoader::Name() );
573
574         if ( filename != NULL ) {
575                 g_strLastModelFolder = g_path_get_dirname( filename );
576                 // use VFS to get the correct relative path
577                 const char *relative = path_make_relative( filename, GlobalFileSystem().findRoot( filename ) );
578                 if ( relative == filename ) {
579                         globalOutputStream() << "WARNING: could not extract the relative path, using full path instead\n";
580                 }
581                 return relative;
582         }
583         return 0;
584 }
585 /*
586 struct LightRadii {
587         static void Export(const EntityCreator &self, const Callback<void(bool)> &returnz) {
588                 returnz(self.getLightRadii());
589         }
590
591         static void Import(EntityCreator &self, bool value) {
592                 self.setLightRadii(value);
593         }
594 };
595
596 void Entity_constructPreferences( PreferencesPage& page ){
597         page.appendCheckBox(
598                         "Show", "Light Radii",
599                         make_property<LightRadii>(GlobalEntityCreator())
600         );
601 }
602 void Entity_constructPage( PreferenceGroup& group ){
603         PreferencesPage page( group.createPage( "Entities", "Entity Display Preferences" ) );
604         Entity_constructPreferences( page );
605 }
606
607 void Entity_registerPreferencesPage(){
608         PreferencesDialog_addDisplayPage( makeCallbackF(Entity_constructPage) );
609 }
610 */
611
612 void ShowLightRadiiToggle(){
613         GlobalEntityCreator().setLightRadii( !GlobalEntityCreator().getLightRadii() );
614         UpdateAllWindows();
615 }
616 typedef FreeCaller<void(), ShowLightRadiiToggle> ShowLightRadiiToggleCaller;
617 void ShowLightRadiiExport( const Callback<void(bool)> & importer ){
618         GlobalEntityCreator().getLightRadii();
619 }
620 typedef FreeCaller<void(const Callback<void(bool)> &), ShowLightRadiiExport> ShowLightRadiiExportCaller;
621
622 ShowLightRadiiExportCaller g_show_lightradii_caller;
623 Callback<void(const Callback<void(bool)> &)> g_show_lightradii_callback( g_show_lightradii_caller );
624 ToggleItem g_show_lightradii( g_show_lightradii_callback );
625
626 void Entity_constructMenu( ui::Menu menu ){
627         create_menu_item_with_mnemonic( menu, "_Regroup", "GroupSelection" );
628         create_menu_item_with_mnemonic( menu, "_Ungroup", "UngroupSelection" );
629         create_menu_item_with_mnemonic( menu, "_Connect", "ConnectSelection" );
630         if ( g_pGameDescription->mGameType == "nexuiz" ) {
631                 create_menu_item_with_mnemonic( menu, "_KillConnect", "KillConnectSelection" );
632         }
633         create_menu_item_with_mnemonic( menu, "_Select Color...", "EntityColor" );
634         create_menu_item_with_mnemonic( menu, "_Normalize Color", "NormalizeColor" );
635 }
636
637
638 void Entity_Construct(){
639         GlobalCommands_insert( "EntityColor", makeCallbackF(Entity_setColour), Accelerator( 'K' ) );
640         GlobalCommands_insert( "NormalizeColor", makeCallbackF(Entity_normalizeColor) );
641         GlobalCommands_insert( "ConnectSelection", makeCallbackF(Entity_connectSelected), Accelerator( 'K', (GdkModifierType)GDK_CONTROL_MASK ) );
642         GlobalCommands_insert( "KillConnectSelection", makeCallbackF(Entity_killconnectSelected), Accelerator( 'K', (GdkModifierType)( GDK_SHIFT_MASK ) ) );
643         GlobalCommands_insert( "GroupSelection", makeCallbackF(Entity_groupSelected) );
644         GlobalCommands_insert( "UngroupSelection", makeCallbackF(Entity_ungroupSelected) );
645
646         GlobalToggles_insert( "ShowLightRadiuses", makeCallbackF( ShowLightRadiiToggle ), ToggleItem::AddCallbackCaller( g_show_lightradii ) );
647
648         GlobalPreferenceSystem().registerPreference( "SI_Colors5", make_property_string( g_entity_globals.color_entity ) );
649         GlobalPreferenceSystem().registerPreference( "LastLightIntensity", make_property_string( g_iLastLightIntensity ) );
650
651 //      Entity_registerPreferencesPage();
652 }
653
654 void Entity_Destroy(){
655 }