2 Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
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.
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.
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
22 #include "entityinspector.h"
24 #include "debugging/debugging.h"
28 #include "ifilesystem.h"
30 #include "iscenegraph.h"
31 #include "iselection.h"
36 #include <gdk/gdkkeysyms.h>
37 #include <uilib/uilib.h>
41 #include "eclasslib.h"
43 #include "generic/callback.h"
45 #include "stream/stringstream.h"
46 #include "moduleobserver.h"
50 #include "gtkutil/accelerator.h"
51 #include "gtkutil/dialog.h"
52 #include "gtkutil/filechooser.h"
53 #include "gtkutil/messagebox.h"
54 #include "gtkutil/nonmodal.h"
55 #include "gtkutil/button.h"
56 #include "gtkutil/entry.h"
57 #include "gtkutil/container.h"
63 #include "mainframe.h"
64 #include "textureentry.h"
65 #include "groupdialog.h"
67 ui::Entry numeric_entry_new(){
68 auto entry = ui::Entry(ui::New);
70 entry.dimensions(64, -1);
76 typedef std::map<CopiedString, CopiedString> KeyValues;
77 KeyValues g_selectedKeyValues;
78 KeyValues g_selectedDefaultKeyValues;
81 const char* SelectedEntity_getValueForKey( const char* key ){
83 KeyValues::const_iterator i = g_selectedKeyValues.find( key );
84 if ( i != g_selectedKeyValues.end() ) {
85 return ( *i ).second.c_str();
89 KeyValues::const_iterator i = g_selectedDefaultKeyValues.find( key );
90 if ( i != g_selectedDefaultKeyValues.end() ) {
91 return ( *i ).second.c_str();
97 void Scene_EntitySetKeyValue_Selected_Undoable( const char* key, const char* value ){
98 StringOutputStream command( 256 );
99 command << "entitySetKeyValue -key " << makeQuoted( key ) << " -value " << makeQuoted( value );
100 UndoableCommand undo( command.c_str() );
101 Scene_EntitySetKeyValue_Selected( key, value );
104 class EntityAttribute
107 virtual ~EntityAttribute() = default;
108 virtual ui::Widget getWidget() const = 0;
109 virtual void update() = 0;
110 virtual void release() = 0;
113 class BooleanAttribute : public EntityAttribute
116 ui::CheckButton m_check;
118 static gboolean toggled( ui::Widget widget, BooleanAttribute* self ){
123 BooleanAttribute( const char* key ) :
126 auto check = ui::CheckButton(ui::New);
131 guint handler = check.connect( "toggled", G_CALLBACK( toggled ), this );
132 g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( handler ) );
136 ui::Widget getWidget() const {
143 Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), m_check.active() ? "1" : "0" );
145 typedef MemberCaller<BooleanAttribute, void(), &BooleanAttribute::apply> ApplyCaller;
148 const char* value = SelectedEntity_getValueForKey( m_key.c_str() );
149 if ( !string_empty( value ) ) {
150 toggle_button_set_active_no_signal( m_check, atoi( value ) != 0 );
154 toggle_button_set_active_no_signal( m_check, false );
157 typedef MemberCaller<BooleanAttribute, void(), &BooleanAttribute::update> UpdateCaller;
161 class StringAttribute : public EntityAttribute
165 NonModalEntry m_nonModal;
167 StringAttribute( const char* key ) :
170 m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ){
171 auto entry = ui::Entry(ui::New);
173 entry.dimensions(50, -1);
176 m_nonModal.connect( m_entry );
178 ui::Widget getWidget() const {
181 ui::Entry getEntry() const {
189 StringOutputStream value( 64 );
190 value << m_entry.text();
191 Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), value.c_str() );
193 typedef MemberCaller<StringAttribute, void(), &StringAttribute::apply> ApplyCaller;
196 StringOutputStream value( 64 );
197 value << SelectedEntity_getValueForKey( m_key.c_str() );
198 m_entry.text(value.c_str());
200 typedef MemberCaller<StringAttribute, void(), &StringAttribute::update> UpdateCaller;
203 class ShaderAttribute : public StringAttribute
206 ShaderAttribute( const char* key ) : StringAttribute( key ){
207 GlobalShaderEntryCompletion::instance().connect( StringAttribute::getEntry() );
212 class ModelAttribute : public EntityAttribute
215 BrowsedPathEntry m_entry;
216 NonModalEntry m_nonModal;
218 ModelAttribute( const char* key ) :
220 m_entry( BrowseCaller( *this ) ),
221 m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ){
222 m_nonModal.connect( m_entry.m_entry.m_entry );
227 ui::Widget getWidget() const {
228 return m_entry.m_entry.m_frame;
231 StringOutputStream value( 64 );
232 value << m_entry.m_entry.m_entry.text();
233 Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), value.c_str() );
235 typedef MemberCaller<ModelAttribute, void(), &ModelAttribute::apply> ApplyCaller;
237 StringOutputStream value( 64 );
238 value << SelectedEntity_getValueForKey( m_key.c_str() );
239 m_entry.m_entry.m_entry.text(value.c_str());
241 typedef MemberCaller<ModelAttribute, void(), &ModelAttribute::update> UpdateCaller;
242 void browse( const BrowsedPathEntry::SetPathCallback& setPath ){
243 const char *filename = misc_model_dialog( m_entry.m_entry.m_frame.window() );
245 if ( filename != 0 ) {
250 typedef MemberCaller<ModelAttribute, void(const BrowsedPathEntry::SetPathCallback&), &ModelAttribute::browse> BrowseCaller;
253 const char* browse_sound( ui::Widget parent ){
254 StringOutputStream buffer( 1024 );
256 buffer << g_qeglobals.m_userGamePath.c_str() << "sound/";
258 if ( !file_readable( buffer.c_str() ) ) {
261 buffer << g_qeglobals.m_userGamePath.c_str() << "/";
264 const char* filename = parent.file_dialog(TRUE, "Open Wav File", buffer.c_str(), "sound" );
265 if ( filename != 0 ) {
266 const char* relative = path_make_relative( filename, GlobalFileSystem().findRoot( filename ) );
267 if ( relative == filename ) {
268 globalOutputStream() << "WARNING: could not extract the relative path, using full path instead\n";
275 class SoundAttribute : public EntityAttribute
278 BrowsedPathEntry m_entry;
279 NonModalEntry m_nonModal;
281 SoundAttribute( const char* key ) :
283 m_entry( BrowseCaller( *this ) ),
284 m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ){
285 m_nonModal.connect( m_entry.m_entry.m_entry );
290 ui::Widget getWidget() const {
291 return ui::Widget(m_entry.m_entry.m_frame );
294 StringOutputStream value( 64 );
295 value << m_entry.m_entry.m_entry.text();
296 Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), value.c_str() );
298 typedef MemberCaller<SoundAttribute, void(), &SoundAttribute::apply> ApplyCaller;
300 StringOutputStream value( 64 );
301 value << SelectedEntity_getValueForKey( m_key.c_str() );
302 m_entry.m_entry.m_entry.text(value.c_str());
304 typedef MemberCaller<SoundAttribute, void(), &SoundAttribute::update> UpdateCaller;
305 void browse( const BrowsedPathEntry::SetPathCallback& setPath ){
306 const char *filename = browse_sound( m_entry.m_entry.m_frame.window() );
308 if ( filename != 0 ) {
313 typedef MemberCaller<SoundAttribute, void(const BrowsedPathEntry::SetPathCallback&), &SoundAttribute::browse> BrowseCaller;
316 inline double angle_normalised( double angle ){
317 return float_mod( angle, 360.0 );
320 class AngleAttribute : public EntityAttribute
324 NonModalEntry m_nonModal;
326 AngleAttribute( const char* key ) :
329 m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ){
330 auto entry = numeric_entry_new();
332 m_nonModal.connect( m_entry );
337 ui::Widget getWidget() const {
338 return ui::Widget(m_entry );
341 StringOutputStream angle( 32 );
342 angle << angle_normalised( entry_get_float( m_entry ) );
343 Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), angle.c_str() );
345 typedef MemberCaller<AngleAttribute, void(), &AngleAttribute::apply> ApplyCaller;
348 const char* value = SelectedEntity_getValueForKey( m_key.c_str() );
349 if ( !string_empty( value ) ) {
350 StringOutputStream angle( 32 );
351 angle << angle_normalised( atof( value ) );
352 m_entry.text(angle.c_str());
359 typedef MemberCaller<AngleAttribute, void(), &AngleAttribute::update> UpdateCaller;
364 typedef const char* String;
365 const String buttons[] = { "up", "down", "z-axis" };
368 class DirectionAttribute : public EntityAttribute
372 NonModalEntry m_nonModal;
374 NonModalRadio m_nonModalRadio;
375 ui::HBox m_hbox{ui::null};
377 DirectionAttribute( const char* key ) :
380 m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ),
381 m_radio( RadioHBox_new( STRING_ARRAY_RANGE( buttons ) ) ),
382 m_nonModalRadio( ApplyRadioCaller( *this ) ){
383 auto entry = numeric_entry_new();
385 m_nonModal.connect( m_entry );
387 m_nonModalRadio.connect( m_radio.m_radio );
389 m_hbox = ui::HBox( FALSE, 4 );
392 m_hbox.pack_start( m_radio.m_hbox, TRUE, TRUE, 0 );
393 m_hbox.pack_start( m_entry, TRUE, TRUE, 0 );
398 ui::Widget getWidget() const {
399 return ui::Widget(m_hbox );
402 StringOutputStream angle( 32 );
403 angle << angle_normalised( entry_get_float( m_entry ) );
404 Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), angle.c_str() );
406 typedef MemberCaller<DirectionAttribute, void(), &DirectionAttribute::apply> ApplyCaller;
409 const char* value = SelectedEntity_getValueForKey( m_key.c_str() );
410 if ( !string_empty( value ) ) {
411 float f = float(atof( value ) );
413 gtk_widget_set_sensitive( m_entry , FALSE );
414 radio_button_set_active_no_signal( m_radio.m_radio, 0 );
417 else if ( f == -2 ) {
418 gtk_widget_set_sensitive( m_entry , FALSE );
419 radio_button_set_active_no_signal( m_radio.m_radio, 1 );
424 gtk_widget_set_sensitive( m_entry , TRUE );
425 radio_button_set_active_no_signal( m_radio.m_radio, 2 );
426 StringOutputStream angle( 32 );
427 angle << angle_normalised( f );
428 m_entry.text(angle.c_str());
436 typedef MemberCaller<DirectionAttribute, void(), &DirectionAttribute::update> UpdateCaller;
439 int index = radio_button_get_active( m_radio.m_radio );
441 Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), "-1" );
443 else if ( index == 1 ) {
444 Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), "-2" );
446 else if ( index == 2 ) {
450 typedef MemberCaller<DirectionAttribute, void(), &DirectionAttribute::applyRadio> ApplyRadioCaller;
460 AnglesEntry() : m_roll( ui::null ), m_pitch( ui::null ), m_yaw( ui::null ){
464 typedef BasicVector3<double> DoubleVector3;
466 class AnglesAttribute : public EntityAttribute
469 AnglesEntry m_angles;
470 NonModalEntry m_nonModal;
473 AnglesAttribute( const char* key ) :
475 m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ),
476 m_hbox(ui::HBox( TRUE, 4 ))
480 auto entry = numeric_entry_new();
481 m_hbox.pack_start( entry, TRUE, TRUE, 0 );
482 m_angles.m_pitch = entry;
483 m_nonModal.connect( m_angles.m_pitch );
486 auto entry = numeric_entry_new();
487 m_hbox.pack_start( entry, TRUE, TRUE, 0 );
488 m_angles.m_yaw = entry;
489 m_nonModal.connect( m_angles.m_yaw );
492 auto entry = numeric_entry_new();
493 m_hbox.pack_start( entry, TRUE, TRUE, 0 );
494 m_angles.m_roll = entry;
495 m_nonModal.connect( m_angles.m_roll );
501 ui::Widget getWidget() const {
502 return ui::Widget(m_hbox );
505 StringOutputStream angles( 64 );
506 angles << angle_normalised( entry_get_float( m_angles.m_pitch ) )
507 << " " << angle_normalised( entry_get_float( m_angles.m_yaw ) )
508 << " " << angle_normalised( entry_get_float( m_angles.m_roll ) );
509 Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), angles.c_str() );
511 typedef MemberCaller<AnglesAttribute, void(), &AnglesAttribute::apply> ApplyCaller;
514 StringOutputStream angle( 32 );
515 const char* value = SelectedEntity_getValueForKey( m_key.c_str() );
516 if ( !string_empty( value ) ) {
517 DoubleVector3 pitch_yaw_roll;
518 if ( !string_parse_vector3( value, pitch_yaw_roll ) ) {
519 pitch_yaw_roll = DoubleVector3( 0, 0, 0 );
522 angle << angle_normalised( pitch_yaw_roll.x() );
523 m_angles.m_pitch.text(angle.c_str());
526 angle << angle_normalised( pitch_yaw_roll.y() );
527 m_angles.m_yaw.text(angle.c_str());
530 angle << angle_normalised( pitch_yaw_roll.z() );
531 m_angles.m_roll.text(angle.c_str());
536 m_angles.m_pitch.text("0");
537 m_angles.m_yaw.text("0");
538 m_angles.m_roll.text("0");
541 typedef MemberCaller<AnglesAttribute, void(), &AnglesAttribute::update> UpdateCaller;
550 Vector3Entry() : m_x( ui::null ), m_y( ui::null ), m_z( ui::null ){
554 class Vector3Attribute : public EntityAttribute
557 Vector3Entry m_vector3;
558 NonModalEntry m_nonModal;
559 ui::Box m_hbox{ui::null};
561 Vector3Attribute( const char* key ) :
563 m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ){
564 m_hbox = ui::HBox( TRUE, 4 );
567 auto entry = numeric_entry_new();
568 m_hbox.pack_start( entry, TRUE, TRUE, 0 );
569 m_vector3.m_x = entry;
570 m_nonModal.connect( m_vector3.m_x );
573 auto entry = numeric_entry_new();
574 m_hbox.pack_start( entry, TRUE, TRUE, 0 );
575 m_vector3.m_y = entry;
576 m_nonModal.connect( m_vector3.m_y );
579 auto entry = numeric_entry_new();
580 m_hbox.pack_start( entry, TRUE, TRUE, 0 );
581 m_vector3.m_z = entry;
582 m_nonModal.connect( m_vector3.m_z );
588 ui::Widget getWidget() const {
589 return ui::Widget(m_hbox );
592 StringOutputStream vector3( 64 );
593 vector3 << entry_get_float( m_vector3.m_x )
594 << " " << entry_get_float( m_vector3.m_y )
595 << " " << entry_get_float( m_vector3.m_z );
596 Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), vector3.c_str() );
598 typedef MemberCaller<Vector3Attribute, void(), &Vector3Attribute::apply> ApplyCaller;
601 StringOutputStream buffer( 32 );
602 const char* value = SelectedEntity_getValueForKey( m_key.c_str() );
603 if ( !string_empty( value ) ) {
605 if ( !string_parse_vector3( value, x_y_z ) ) {
606 x_y_z = DoubleVector3( 0, 0, 0 );
610 m_vector3.m_x.text(buffer.c_str());
614 m_vector3.m_y.text(buffer.c_str());
618 m_vector3.m_z.text(buffer.c_str());
623 m_vector3.m_x.text("0");
624 m_vector3.m_y.text("0");
625 m_vector3.m_z.text("0");
628 typedef MemberCaller<Vector3Attribute, void(), &Vector3Attribute::update> UpdateCaller;
631 class NonModalComboBox
633 Callback<void()> m_changed;
634 guint m_changedHandler;
636 static gboolean changed( ui::ComboBox widget, NonModalComboBox* self ){
642 NonModalComboBox( const Callback<void()>& changed ) : m_changed( changed ), m_changedHandler( 0 ){
644 void connect( ui::ComboBox combo ){
645 m_changedHandler = combo.connect( "changed", G_CALLBACK( changed ), this );
647 void setActive( ui::ComboBox combo, int value ){
648 g_signal_handler_disconnect( G_OBJECT( combo ), m_changedHandler );
649 gtk_combo_box_set_active( combo, value );
654 class ListAttribute : public EntityAttribute
657 ui::ComboBox m_combo;
658 NonModalComboBox m_nonModal;
659 const ListAttributeType& m_type;
661 ListAttribute( const char* key, const ListAttributeType& type ) :
664 m_nonModal( ApplyCaller( *this ) ),
666 auto combo = ui::ComboBoxText(ui::New);
668 for ( ListAttributeType::const_iterator i = type.begin(); i != type.end(); ++i )
670 gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT( combo ), ( *i ).first.c_str() );
674 m_nonModal.connect( combo );
681 ui::Widget getWidget() const {
682 return ui::Widget(m_combo );
685 Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), m_type[gtk_combo_box_get_active( m_combo )].second.c_str() );
687 typedef MemberCaller<ListAttribute, void(), &ListAttribute::apply> ApplyCaller;
690 const char* value = SelectedEntity_getValueForKey( m_key.c_str() );
691 ListAttributeType::const_iterator i = m_type.findValue( value );
692 if ( i != m_type.end() ) {
693 m_nonModal.setActive( m_combo, static_cast<int>( std::distance( m_type.begin(), i ) ) );
697 m_nonModal.setActive( m_combo, 0 );
700 typedef MemberCaller<ListAttribute, void(), &ListAttribute::update> UpdateCaller;
706 ui::Widget g_entity_split1{ui::null};
707 ui::Widget g_entity_split2{ui::null};
708 int g_entitysplit1_position;
709 int g_entitysplit2_position;
711 bool g_entityInspector_windowConstructed = false;
713 ui::TreeView g_entityClassList{ui::null};
714 ui::TextView g_entityClassComment{ui::null};
716 GtkCheckButton* g_entitySpawnflagsCheck[MAX_FLAGS];
718 ui::Entry g_entityKeyEntry{ui::null};
719 ui::Entry g_entityValueEntry{ui::null};
721 ui::ListStore g_entlist_store{ui::null};
722 ui::ListStore g_entprops_store{ui::null};
723 const EntityClass* g_current_flags = 0;
724 const EntityClass* g_current_comment = 0;
725 const EntityClass* g_current_attributes = 0;
727 // the number of active spawnflags
728 int g_spawnflag_count;
729 // table: index, match spawnflag item to the spawnflag index (i.e. which bit)
730 int spawn_table[MAX_FLAGS];
731 // we change the layout depending on how many spawn flags we need to display
732 // the table is a 4x4 in which we need to put the comment box g_entityClassComment and the spawn flags..
733 ui::Table g_spawnflagsTable{ui::null};
735 ui::VBox g_attributeBox{ui::null};
736 typedef std::vector<EntityAttribute*> EntityAttributes;
737 EntityAttributes g_entityAttributes;
740 void GlobalEntityAttributes_clear(){
741 for ( EntityAttributes::iterator i = g_entityAttributes.begin(); i != g_entityAttributes.end(); ++i )
745 g_entityAttributes.clear();
748 class GetKeyValueVisitor : public Entity::Visitor
750 KeyValues& m_keyvalues;
752 GetKeyValueVisitor( KeyValues& keyvalues )
753 : m_keyvalues( keyvalues ){
756 void visit( const char* key, const char* value ){
757 m_keyvalues.insert( KeyValues::value_type( CopiedString( key ), CopiedString( value ) ) );
762 void Entity_GetKeyValues( const Entity& entity, KeyValues& keyvalues, KeyValues& defaultValues ){
763 GetKeyValueVisitor visitor( keyvalues );
765 entity.forEachKeyValue( visitor );
767 const EntityClassAttributes& attributes = entity.getEntityClass().m_attributes;
769 for ( EntityClassAttributes::const_iterator i = attributes.begin(); i != attributes.end(); ++i )
771 defaultValues.insert( KeyValues::value_type( ( *i ).first, ( *i ).second.m_value ) );
775 void Entity_GetKeyValues_Selected( KeyValues& keyvalues, KeyValues& defaultValues ){
776 class EntityGetKeyValues : public SelectionSystem::Visitor
778 KeyValues& m_keyvalues;
779 KeyValues& m_defaultValues;
780 mutable std::set<Entity*> m_visited;
782 EntityGetKeyValues( KeyValues& keyvalues, KeyValues& defaultValues )
783 : m_keyvalues( keyvalues ), m_defaultValues( defaultValues ){
785 void visit( scene::Instance& instance ) const {
786 Entity* entity = Node_getEntity( instance.path().top() );
787 if ( entity == 0 && instance.path().size() != 1 ) {
788 entity = Node_getEntity( instance.path().parent() );
790 if ( entity != 0 && m_visited.insert( entity ).second ) {
791 Entity_GetKeyValues( *entity, m_keyvalues, m_defaultValues );
794 } visitor( keyvalues, defaultValues );
795 GlobalSelectionSystem().foreachSelected( visitor );
798 const char* keyvalues_valueforkey( KeyValues& keyvalues, const char* key ){
799 KeyValues::iterator i = keyvalues.find( CopiedString( key ) );
800 if ( i != keyvalues.end() ) {
801 return ( *i ).second.c_str();
806 class EntityClassListStoreAppend : public EntityClassVisitor
810 EntityClassListStoreAppend( ui::ListStore store_ ) : store( store_ ){
812 void visit( EntityClass* e ){
813 store.append(0, e->name(), 1, e);
817 void EntityClassList_fill(){
818 EntityClassListStoreAppend append( g_entlist_store );
819 GlobalEntityClassManager().forEach( append );
822 void EntityClassList_clear(){
823 g_entlist_store.clear();
826 void SetComment( EntityClass* eclass ){
827 if ( eclass == g_current_comment ) {
831 g_current_comment = eclass;
833 g_entityClassComment.text(eclass->comments());
836 void SurfaceFlags_setEntityClass( EntityClass* eclass ){
837 if ( eclass == g_current_flags ) {
841 g_current_flags = eclass;
843 unsigned int spawnflag_count = 0;
846 // do a first pass to count the spawn flags, don't touch the widgets, we don't know in what state they are
847 for ( int i = 0 ; i < MAX_FLAGS ; i++ )
849 if ( eclass->flagnames[i] && eclass->flagnames[i][0] != 0 && strcmp( eclass->flagnames[i],"-" ) ) {
850 spawn_table[spawnflag_count] = i;
856 // disable all remaining boxes
857 // NOTE: these boxes might not even be on display
859 for ( int i = 0; i < g_spawnflag_count; ++i )
861 auto widget = ui::CheckButton::from(g_entitySpawnflagsCheck[i]);
862 auto label = ui::Label::from(gtk_bin_get_child(GTK_BIN(widget)));
866 g_spawnflagsTable.remove(widget);
870 g_spawnflag_count = spawnflag_count;
873 for (unsigned int i = 0; (int) i < g_spawnflag_count; ++i)
875 auto widget = ui::CheckButton::from(g_entitySpawnflagsCheck[i] );
878 StringOutputStream str( 16 );
879 str << LowerCase( eclass->flagnames[spawn_table[i]] );
881 g_spawnflagsTable.attach(widget, {i % 4, i % 4 + 1, i / 4, i / 4 + 1}, {GTK_FILL, GTK_FILL});
884 auto label = ui::Label::from(gtk_bin_get_child(GTK_BIN(widget)) );
885 label.text(str.c_str());
890 void EntityClassList_selectEntityClass( EntityClass* eclass ){
891 auto model = g_entlist_store;
893 for ( gboolean good = gtk_tree_model_get_iter_first( model, &iter ); good != FALSE; good = gtk_tree_model_iter_next( model, &iter ) )
896 gtk_tree_model_get( model, &iter, 0, &text, -1 );
897 if ( strcmp( text, eclass->name() ) == 0 ) {
898 auto view = ui::TreeView(g_entityClassList);
899 auto path = gtk_tree_model_get_path( model, &iter );
900 gtk_tree_selection_select_path( gtk_tree_view_get_selection( view ), path );
901 if ( gtk_widget_get_realized( view ) ) {
902 gtk_tree_view_scroll_to_cell( view, path, 0, FALSE, 0, 0 );
904 gtk_tree_path_free( path );
911 void EntityInspector_appendAttribute( const char* name, EntityAttribute& attribute ){
912 auto row = DialogRow_new( name, attribute.getWidget() );
913 DialogVBox_packRow( ui::VBox(g_attributeBox), row );
917 template<typename Attribute>
918 class StatelessAttributeCreator
921 static EntityAttribute* create( const char* name ){
922 return new Attribute( name );
926 class EntityAttributeFactory
928 typedef EntityAttribute* ( *CreateFunc )( const char* name );
929 typedef std::map<const char*, CreateFunc, RawStringLess> Creators;
932 EntityAttributeFactory(){
933 m_creators.insert( Creators::value_type( "string", &StatelessAttributeCreator<StringAttribute>::create ) );
934 m_creators.insert( Creators::value_type( "color", &StatelessAttributeCreator<StringAttribute>::create ) );
935 m_creators.insert( Creators::value_type( "integer", &StatelessAttributeCreator<StringAttribute>::create ) );
936 m_creators.insert( Creators::value_type( "real", &StatelessAttributeCreator<StringAttribute>::create ) );
937 m_creators.insert( Creators::value_type( "shader", &StatelessAttributeCreator<ShaderAttribute>::create ) );
938 m_creators.insert( Creators::value_type( "boolean", &StatelessAttributeCreator<BooleanAttribute>::create ) );
939 m_creators.insert( Creators::value_type( "angle", &StatelessAttributeCreator<AngleAttribute>::create ) );
940 m_creators.insert( Creators::value_type( "direction", &StatelessAttributeCreator<DirectionAttribute>::create ) );
941 m_creators.insert( Creators::value_type( "angles", &StatelessAttributeCreator<AnglesAttribute>::create ) );
942 m_creators.insert( Creators::value_type( "model", &StatelessAttributeCreator<ModelAttribute>::create ) );
943 m_creators.insert( Creators::value_type( "sound", &StatelessAttributeCreator<SoundAttribute>::create ) );
944 m_creators.insert( Creators::value_type( "vector3", &StatelessAttributeCreator<Vector3Attribute>::create ) );
945 m_creators.insert( Creators::value_type( "real3", &StatelessAttributeCreator<Vector3Attribute>::create ) );
947 EntityAttribute* create( const char* type, const char* name ){
948 Creators::iterator i = m_creators.find( type );
949 if ( i != m_creators.end() ) {
950 return ( *i ).second( name );
952 const ListAttributeType* listType = GlobalEntityClassManager().findListType( type );
953 if ( listType != 0 ) {
954 return new ListAttribute( name, *listType );
960 typedef Static<EntityAttributeFactory> GlobalEntityAttributeFactory;
962 void EntityInspector_setEntityClass( EntityClass *eclass ){
963 EntityClassList_selectEntityClass( eclass );
964 SurfaceFlags_setEntityClass( eclass );
966 if ( eclass != g_current_attributes ) {
967 g_current_attributes = eclass;
969 container_remove_all( g_attributeBox );
970 GlobalEntityAttributes_clear();
972 for ( EntityClassAttributes::const_iterator i = eclass->m_attributes.begin(); i != eclass->m_attributes.end(); ++i )
974 EntityAttribute* attribute = GlobalEntityAttributeFactory::instance().create( ( *i ).second.m_type.c_str(), ( *i ).first.c_str() );
975 if ( attribute != 0 ) {
976 g_entityAttributes.push_back( attribute );
977 EntityInspector_appendAttribute( EntityClassAttributePair_getName( *i ), *g_entityAttributes.back() );
983 void EntityInspector_updateSpawnflags(){
985 int f = atoi( SelectedEntity_getValueForKey( "spawnflags" ) );
986 for ( int i = 0; i < g_spawnflag_count; ++i )
988 int v = !!( f & ( 1 << spawn_table[i] ) );
990 toggle_button_set_active_no_signal( ui::ToggleButton::from( g_entitySpawnflagsCheck[i] ), v );
994 // take care of the remaining ones
995 for ( int i = g_spawnflag_count; i < MAX_FLAGS; ++i )
997 toggle_button_set_active_no_signal( ui::ToggleButton::from( g_entitySpawnflagsCheck[i] ), FALSE );
1002 void EntityInspector_applySpawnflags(){
1007 for ( i = 0; i < g_spawnflag_count; ++i )
1009 v = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( g_entitySpawnflagsCheck[i] ) );
1010 f |= v << spawn_table[i];
1013 sprintf( sz, "%i", f );
1014 const char* value = ( f == 0 ) ? "" : sz;
1017 StringOutputStream command;
1018 command << "entitySetFlags -flags " << f;
1019 UndoableCommand undo( "entitySetSpawnflags" );
1021 Scene_EntitySetKeyValue_Selected( "spawnflags", value );
1026 void EntityInspector_updateKeyValues(){
1027 g_selectedKeyValues.clear();
1028 g_selectedDefaultKeyValues.clear();
1029 Entity_GetKeyValues_Selected( g_selectedKeyValues, g_selectedDefaultKeyValues );
1031 EntityInspector_setEntityClass( GlobalEntityClassManager().findOrInsert( keyvalues_valueforkey( g_selectedKeyValues, "classname" ), false ) );
1033 EntityInspector_updateSpawnflags();
1035 ui::ListStore store = g_entprops_store;
1037 // save current key/val pair around filling epair box
1038 // row_select wipes it and sets to first in list
1039 CopiedString strKey( g_entityKeyEntry.text() );
1040 CopiedString strVal( g_entityValueEntry.text() );
1043 // Walk through list and add pairs
1044 for ( KeyValues::iterator i = g_selectedKeyValues.begin(); i != g_selectedKeyValues.end(); ++i )
1046 StringOutputStream key( 64 );
1047 key << ( *i ).first.c_str();
1048 StringOutputStream value( 64 );
1049 value << ( *i ).second.c_str();
1050 store.append(0, key.c_str(), 1, value.c_str());
1053 g_entityKeyEntry.text( strKey.c_str() );
1054 g_entityValueEntry.text( strVal.c_str() );
1056 for ( EntityAttributes::const_iterator i = g_entityAttributes.begin(); i != g_entityAttributes.end(); ++i )
1062 class EntityInspectorDraw
1064 IdleDraw m_idleDraw;
1066 EntityInspectorDraw() : m_idleDraw( makeCallbackF(EntityInspector_updateKeyValues) ){
1069 m_idleDraw.queueDraw();
1073 EntityInspectorDraw g_EntityInspectorDraw;
1076 void EntityInspector_keyValueChanged(){
1077 g_EntityInspectorDraw.queueDraw();
1079 void EntityInspector_selectionChanged( const Selectable& ){
1080 EntityInspector_keyValueChanged();
1083 // Creates a new entity based on the currently selected brush and entity type.
1085 void EntityClassList_createEntity(){
1086 auto view = g_entityClassList;
1088 // find out what type of entity we are trying to create
1089 GtkTreeModel* model;
1091 if ( gtk_tree_selection_get_selected( gtk_tree_view_get_selection( g_entityClassList ), &model, &iter ) == FALSE ) {
1092 ui::alert( view.window(), "You must have a selected class to create an entity", "info" );
1097 gtk_tree_model_get( model, &iter, 0, &text, -1 );
1100 StringOutputStream command;
1101 command << "entityCreate -class " << text;
1103 UndoableCommand undo( command.c_str() );
1105 Entity_createFromSelection( text, g_vector3_identity );
1110 void EntityInspector_applyKeyValue(){
1111 // Get current selection text
1112 StringOutputStream key( 64 );
1113 key << gtk_entry_get_text( g_entityKeyEntry );
1114 StringOutputStream value( 64 );
1115 value << gtk_entry_get_text( g_entityValueEntry );
1118 // TTimo: if you change the classname to worldspawn you won't merge back in the structural brushes but create a parasite entity
1119 if ( !strcmp( key.c_str(), "classname" ) && !strcmp( value.c_str(), "worldspawn" ) ) {
1120 ui::alert( g_entityKeyEntry.window(), "Cannot change \"classname\" key back to worldspawn.", 0, ui::alert_type::OK );
1125 // RR2DO2: we don't want spaces in entity keys
1126 if ( strstr( key.c_str(), " " ) ) {
1127 ui::alert( g_entityKeyEntry.window(), "No spaces are allowed in entity keys.", 0, ui::alert_type::OK );
1131 if ( strcmp( key.c_str(), "classname" ) == 0 ) {
1132 StringOutputStream command;
1133 command << "entitySetClass -class " << value.c_str();
1134 UndoableCommand undo( command.c_str() );
1135 Scene_EntitySetClassname_Selected( value.c_str() );
1139 Scene_EntitySetKeyValue_Selected_Undoable( key.c_str(), value.c_str() );
1143 void EntityInspector_clearKeyValue(){
1144 // Get current selection text
1145 StringOutputStream key( 64 );
1146 key << gtk_entry_get_text( g_entityKeyEntry );
1148 if ( strcmp( key.c_str(), "classname" ) != 0 ) {
1149 StringOutputStream command;
1150 command << "entityDeleteKey -key " << key.c_str();
1151 UndoableCommand undo( command.c_str() );
1152 Scene_EntitySetKeyValue_Selected( key.c_str(), "" );
1156 void EntityInspector_clearAllKeyValues(){
1157 UndoableCommand undo( "entityClear" );
1159 // remove all keys except classname
1160 for ( KeyValues::iterator i = g_selectedKeyValues.begin(); i != g_selectedKeyValues.end(); ++i )
1162 if ( strcmp( ( *i ).first.c_str(), "classname" ) != 0 ) {
1163 Scene_EntitySetKeyValue_Selected( ( *i ).first.c_str(), "" );
1168 // =============================================================================
1171 static void EntityClassList_selection_changed( ui::TreeSelection selection, gpointer data ){
1172 GtkTreeModel* model;
1173 GtkTreeIter selected;
1174 if ( gtk_tree_selection_get_selected( selection, &model, &selected ) ) {
1175 EntityClass* eclass;
1176 gtk_tree_model_get( model, &selected, 1, &eclass, -1 );
1177 if ( eclass != 0 ) {
1178 SetComment( eclass );
1183 static gint EntityClassList_button_press( ui::Widget widget, GdkEventButton *event, gpointer data ){
1184 if ( event->type == GDK_2BUTTON_PRESS ) {
1185 EntityClassList_createEntity();
1191 static gint EntityClassList_keypress( ui::Widget widget, GdkEventKey* event, gpointer data ){
1192 unsigned int code = gdk_keyval_to_upper( event->keyval );
1194 if ( event->keyval == GDK_KEY_Return ) {
1195 EntityClassList_createEntity();
1199 // select the entity that starts with the key pressed
1200 if ( code <= 'Z' && code >= 'A' ) {
1201 auto view = ui::TreeView(g_entityClassList);
1202 GtkTreeModel* model;
1204 if ( gtk_tree_selection_get_selected( gtk_tree_view_get_selection( view ), &model, &iter ) == FALSE
1205 || gtk_tree_model_iter_next( model, &iter ) == FALSE ) {
1206 gtk_tree_model_get_iter_first( model, &iter );
1209 for ( std::size_t count = gtk_tree_model_iter_n_children( model, 0 ); count > 0; --count )
1212 gtk_tree_model_get( model, &iter, 0, &text, -1 );
1214 if ( toupper( text[0] ) == (int)code ) {
1215 auto path = gtk_tree_model_get_path( model, &iter );
1216 gtk_tree_selection_select_path( gtk_tree_view_get_selection( view ), path );
1217 if ( gtk_widget_get_realized( view ) ) {
1218 gtk_tree_view_scroll_to_cell( view, path, 0, FALSE, 0, 0 );
1220 gtk_tree_path_free( path );
1226 if ( gtk_tree_model_iter_next( model, &iter ) == FALSE ) {
1227 gtk_tree_model_get_iter_first( model, &iter );
1236 static void EntityProperties_selection_changed( ui::TreeSelection selection, gpointer data ){
1237 // find out what type of entity we are trying to create
1238 GtkTreeModel* model;
1240 if ( gtk_tree_selection_get_selected( selection, &model, &iter ) == FALSE ) {
1246 gtk_tree_model_get( model, &iter, 0, &key, 1, &val, -1 );
1248 g_entityKeyEntry.text( key );
1249 g_entityValueEntry.text( val );
1255 static void SpawnflagCheck_toggled( ui::Widget widget, gpointer data ){
1256 EntityInspector_applySpawnflags();
1259 static gint EntityEntry_keypress( ui::Entry widget, GdkEventKey* event, gpointer data ){
1260 if ( event->keyval == GDK_KEY_Return ) {
1261 if ( widget._handle == g_entityKeyEntry._handle ) {
1262 g_entityValueEntry.text( "" );
1263 gtk_window_set_focus( widget.window(), g_entityValueEntry );
1267 EntityInspector_applyKeyValue();
1271 if ( event->keyval == GDK_KEY_Escape ) {
1272 gtk_window_set_focus( widget.window(), NULL );
1279 void EntityInspector_destroyWindow( ui::Widget widget, gpointer data ){
1280 g_entitysplit1_position = gtk_paned_get_position( GTK_PANED( g_entity_split1 ) );
1281 g_entitysplit2_position = gtk_paned_get_position( GTK_PANED( g_entity_split2 ) );
1283 g_entityInspector_windowConstructed = false;
1284 GlobalEntityAttributes_clear();
1287 ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){
1288 auto vbox = ui::VBox( FALSE, 2 );
1290 gtk_container_set_border_width( GTK_CONTAINER( vbox ), 2 );
1292 vbox.connect( "destroy", G_CALLBACK( EntityInspector_destroyWindow ), 0 );
1295 auto split1 = ui::VPaned(ui::New);
1296 vbox.pack_start( split1, TRUE, TRUE, 0 );
1299 g_entity_split1 = split1;
1302 ui::Widget split2 = ui::VPaned(ui::New);
1303 gtk_paned_add1( GTK_PANED( split1 ), split2 );
1306 g_entity_split2 = split2;
1310 auto scr = ui::ScrolledWindow(ui::New);
1312 gtk_paned_add1( GTK_PANED( split2 ), scr );
1313 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS );
1314 gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN );
1317 ui::ListStore store = ui::ListStore::from(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER ));
1319 auto view = ui::TreeView( ui::TreeModel::from( store._handle ));
1320 gtk_tree_view_set_enable_search(view, FALSE );
1321 gtk_tree_view_set_headers_visible( view, FALSE );
1322 view.connect( "button_press_event", G_CALLBACK( EntityClassList_button_press ), 0 );
1323 view.connect( "key_press_event", G_CALLBACK( EntityClassList_keypress ), 0 );
1326 auto renderer = ui::CellRendererText(ui::New);
1327 auto column = ui::TreeViewColumn( "Key", renderer, {{"text", 0}} );
1328 gtk_tree_view_append_column( view, column );
1332 auto selection = ui::TreeSelection::from(gtk_tree_view_get_selection( view ));
1333 selection.connect( "changed", G_CALLBACK( EntityClassList_selection_changed ), 0 );
1341 g_entityClassList = view;
1342 g_entlist_store = store;
1347 auto scr = ui::ScrolledWindow(ui::New);
1349 gtk_paned_add2( GTK_PANED( split2 ), scr );
1350 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS );
1351 gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN );
1354 auto text = ui::TextView(ui::New);
1355 text.dimensions(0, -1); // allow shrinking
1356 gtk_text_view_set_wrap_mode( text, GTK_WRAP_WORD );
1357 gtk_text_view_set_editable( text, FALSE );
1360 g_entityClassComment = text;
1366 ui::Widget split2 = ui::VPaned(ui::New);
1367 gtk_paned_add2( GTK_PANED( split1 ), split2 );
1371 auto vbox2 = ui::VBox( FALSE, 2 );
1373 gtk_paned_pack1( GTK_PANED( split2 ), vbox2, FALSE, FALSE );
1376 // Spawnflags (4 colums wide max, or window gets too wide.)
1377 auto table = ui::Table( 4, 4, FALSE );
1378 vbox2.pack_start( table, FALSE, TRUE, 0 );
1381 g_spawnflagsTable = table;
1383 for ( int i = 0; i < MAX_FLAGS; i++ )
1385 auto check = ui::CheckButton( "" );
1387 g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( check.connect( "toggled", G_CALLBACK( SpawnflagCheck_toggled ), 0 ) ) );
1388 g_entitySpawnflagsCheck[i] = check;
1394 auto scr = ui::ScrolledWindow(ui::New);
1396 vbox2.pack_start( scr, TRUE, TRUE, 0 );
1397 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
1398 gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN );
1401 ui::ListStore store = ui::ListStore::from(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING ));
1403 auto view = ui::TreeView(ui::TreeModel::from(store._handle));
1404 gtk_tree_view_set_enable_search(view, FALSE );
1405 gtk_tree_view_set_headers_visible(view, FALSE );
1408 auto renderer = ui::CellRendererText(ui::New);
1409 auto column = ui::TreeViewColumn( "", renderer, {{"text", 0}} );
1410 gtk_tree_view_append_column(view, column );
1414 auto renderer = ui::CellRendererText(ui::New);
1415 auto column = ui::TreeViewColumn( "", renderer, {{"text", 1}} );
1416 gtk_tree_view_append_column(view, column );
1420 auto selection = ui::TreeSelection::from(gtk_tree_view_get_selection(view));
1421 selection.connect( "changed", G_CALLBACK( EntityProperties_selection_changed ), 0 );
1430 g_entprops_store = store;
1436 auto table = ui::Table( 2, 2, FALSE );
1438 vbox2.pack_start( table, FALSE, TRUE, 0 );
1439 gtk_table_set_row_spacings( table, 3 );
1440 gtk_table_set_col_spacings( table, 5 );
1443 auto entry = ui::Entry(ui::New);
1445 table.attach(entry, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
1446 gtk_widget_set_events( entry , GDK_KEY_PRESS_MASK );
1447 entry.connect( "key_press_event", G_CALLBACK( EntityEntry_keypress ), 0 );
1448 g_entityKeyEntry = entry;
1452 auto entry = ui::Entry(ui::New);
1454 table.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
1455 gtk_widget_set_events( entry , GDK_KEY_PRESS_MASK );
1456 entry.connect( "key_press_event", G_CALLBACK( EntityEntry_keypress ), 0 );
1457 g_entityValueEntry = entry;
1461 auto label = ui::Label( "Value" );
1463 table.attach(label, {0, 1, 1, 2}, {GTK_FILL, 0});
1464 gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
1468 auto label = ui::Label( "Key" );
1470 table.attach(label, {0, 1, 0, 1}, {GTK_FILL, 0});
1471 gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
1476 auto hbox = ui::HBox( TRUE, 4 );
1478 vbox2.pack_start( hbox, FALSE, TRUE, 0 );
1481 auto button = ui::Button( "Clear All" );
1483 button.connect( "clicked", G_CALLBACK( EntityInspector_clearAllKeyValues ), 0 );
1484 hbox.pack_start( button, TRUE, TRUE, 0 );
1487 auto button = ui::Button( "Delete Key" );
1489 button.connect( "clicked", G_CALLBACK( EntityInspector_clearKeyValue ), 0 );
1490 hbox.pack_start( button, TRUE, TRUE, 0 );
1496 auto scr = ui::ScrolledWindow(ui::New);
1498 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC );
1500 auto viewport = ui::Container::from(gtk_viewport_new( 0, 0 ));
1502 gtk_viewport_set_shadow_type( GTK_VIEWPORT( viewport ), GTK_SHADOW_NONE );
1504 g_attributeBox = ui::VBox( FALSE, 2 );
1505 g_attributeBox.show();
1507 viewport.add(g_attributeBox);
1509 gtk_paned_pack2( GTK_PANED( split2 ), scr, FALSE, FALSE );
1516 // show the sliders in any case
1517 if ( g_entitysplit2_position > 22 ) {
1518 gtk_paned_set_position( GTK_PANED( g_entity_split2 ), g_entitysplit2_position );
1521 g_entitysplit2_position = 22;
1522 gtk_paned_set_position( GTK_PANED( g_entity_split2 ), 22 );
1524 if ( ( g_entitysplit1_position - g_entitysplit2_position ) > 27 ) {
1525 gtk_paned_set_position( GTK_PANED( g_entity_split1 ), g_entitysplit1_position );
1528 gtk_paned_set_position( GTK_PANED( g_entity_split1 ), g_entitysplit2_position + 27 );
1532 g_entityInspector_windowConstructed = true;
1533 EntityClassList_fill();
1535 typedef FreeCaller<void(const Selectable&), EntityInspector_selectionChanged> EntityInspectorSelectionChangedCaller;
1536 GlobalSelectionSystem().addSelectionChangeCallback( EntityInspectorSelectionChangedCaller() );
1537 GlobalEntityCreator().setKeyValueChangedFunc( EntityInspector_keyValueChanged );
1540 gtk_container_set_focus_chain( GTK_CONTAINER( vbox ), NULL );
1545 class EntityInspector : public ModuleObserver
1547 std::size_t m_unrealised;
1549 EntityInspector() : m_unrealised( 1 ){
1552 if ( --m_unrealised == 0 ) {
1553 if ( g_entityInspector_windowConstructed ) {
1554 //globalOutputStream() << "Entity Inspector: realise\n";
1555 EntityClassList_fill();
1560 if ( ++m_unrealised == 1 ) {
1561 if ( g_entityInspector_windowConstructed ) {
1562 //globalOutputStream() << "Entity Inspector: unrealise\n";
1563 EntityClassList_clear();
1569 EntityInspector g_EntityInspector;
1571 #include "preferencesystem.h"
1572 #include "stringio.h"
1574 void EntityInspector_construct(){
1575 GlobalEntityClassManager().attach( g_EntityInspector );
1577 GlobalPreferenceSystem().registerPreference( "EntitySplit1", make_property_string( g_entitysplit1_position ) );
1578 GlobalPreferenceSystem().registerPreference( "EntitySplit2", make_property_string( g_entitysplit2_position ) );
1582 void EntityInspector_destroy(){
1583 GlobalEntityClassManager().detach( g_EntityInspector );
1586 const char *EntityInspector_getCurrentKey(){
1587 if ( !GroupDialog_isShown() ) {
1590 if ( GroupDialog_getPage() != g_page_entity ) {
1593 return gtk_entry_get_text( g_entityKeyEntry );