- ModalDialog dialog;
- GtkEntry* brushes_entry;
- GtkEntry* entities_entry;
- GtkListStore* EntityBreakdownWalker;
-
- GtkWindow* window = create_dialog_window(MainFrame_getWindow(), "Map Info", G_CALLBACK(dialog_delete_callback), &dialog);
-
- window_set_position(window, g_posMapInfoWnd);
-
- {
- GtkVBox* vbox = create_dialog_vbox(4, 4);
- gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(vbox));
-
- {
- GtkHBox* hbox = create_dialog_hbox(4);
- gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbox), FALSE, TRUE, 0);
-
- {
- GtkTable* table = create_dialog_table(2, 2, 4, 4);
- gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(table), TRUE, TRUE, 0);
-
- {
- GtkEntry* entry = GTK_ENTRY(gtk_entry_new());
- gtk_widget_show(GTK_WIDGET(entry));
- gtk_table_attach(table, GTK_WIDGET(entry), 1, 2, 0, 1,
- (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_entry_set_editable(entry, FALSE);
-
- brushes_entry = entry;
- }
- {
- GtkEntry* entry = GTK_ENTRY(gtk_entry_new());
- gtk_widget_show(GTK_WIDGET(entry));
- gtk_table_attach(table, GTK_WIDGET(entry), 1, 2, 1, 2,
- (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_entry_set_editable(entry, FALSE);
-
- entities_entry = entry;
- }
- {
- GtkWidget* label = gtk_label_new ("Total Brushes");
- gtk_widget_show (label);
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
- }
- {
- GtkWidget* label = gtk_label_new ("Total Entities");
- gtk_widget_show (label);
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
- }
- }
- {
- GtkVBox* vbox2 = create_dialog_vbox(4);
- gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(vbox2), FALSE, FALSE, 0);
-
- {
- GtkButton* button = create_dialog_button("Close", G_CALLBACK(dialog_button_ok), &dialog);
- gtk_box_pack_start(GTK_BOX(vbox2), GTK_WIDGET(button), FALSE, FALSE, 0);
- }
- }
- }
- {
- GtkWidget* label = gtk_label_new ("Entity breakdown");
- gtk_widget_show (label);
- gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(label), FALSE, TRUE, 0);
- gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
- }
- {
- GtkScrolledWindow* scr = create_scrolled_window(GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, 4);
- gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET(scr), TRUE, TRUE, 0);
-
- {
- GtkListStore* store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
-
- GtkWidget* view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
- gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(view), TRUE);
-
- {
- GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
- GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("Entity", renderer, "text", 0, 0);
- gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
- gtk_tree_view_column_set_sort_column_id(column, 0);
- }
-
- {
- GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
- GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("Count", renderer, "text", 1, 0);
- gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
- gtk_tree_view_column_set_sort_column_id(column, 1);
- }
-
- gtk_widget_show(view);
-
- gtk_container_add(GTK_CONTAINER(scr), view);
-
- EntityBreakdownWalker = store;
- }
- }
- }
-
- // Initialize fields
-
- {
- EntityBreakdown entitymap;
- Scene_EntityBreakdown(entitymap);
-
- for(EntityBreakdown::iterator i=entitymap.begin(); i != entitymap.end(); ++i)
- {
- char tmp[16];
- sprintf (tmp, "%u", Unsigned((*i).second));
- GtkTreeIter iter;
- gtk_list_store_append(GTK_LIST_STORE(EntityBreakdownWalker), &iter);
- gtk_list_store_set(GTK_LIST_STORE(EntityBreakdownWalker), &iter, 0, (*i).first.c_str(), 1, tmp, -1);
- }
- }
-
- g_object_unref(G_OBJECT(EntityBreakdownWalker));
-
- char tmp[16];
- sprintf (tmp, "%u", Unsigned(g_brushCount.get()));
- gtk_entry_set_text (GTK_ENTRY (brushes_entry), tmp);
- sprintf (tmp, "%u", Unsigned(g_entityCount.get()));
- gtk_entry_set_text (GTK_ENTRY (entities_entry), tmp);
-
- modal_dialog_show(window, dialog);
-
- // save before exit
- window_get_position(window, g_posMapInfoWnd);
-
- gtk_widget_destroy(GTK_WIDGET(window));
+EntityBreakdown& m_entitymap;
+public:
+EntityBreakdownWalker( EntityBreakdown& entitymap )
+ : m_entitymap( entitymap ){
+}
+
+bool pre( const scene::Path& path, scene::Instance& instance ) const {
+ Entity* entity = Node_getEntity( path.top() );
+ if ( entity != 0 ) {
+ const EntityClass& eclass = entity->getEntityClass();
+ if ( m_entitymap.find( eclass.name() ) == m_entitymap.end() ) {
+ m_entitymap[eclass.name()] = 1;
+ } else
+ {
+ ++m_entitymap[eclass.name()];
+ }
+ }
+ return true;
+}
+};
+
+void Scene_EntityBreakdown( EntityBreakdown& entitymap ){
+ GlobalSceneGraph().traverse( EntityBreakdownWalker( entitymap ) );
+}
+
+
+WindowPosition g_posMapInfoWnd( c_default_window_pos );
+
+void DoMapInfo(){
+ ModalDialog dialog;
+ ui::Entry brushes_entry{ui::null};
+ ui::Entry entities_entry{ui::null};
+ ui::ListStore EntityBreakdownWalker{ui::null};
+
+ ui::Window window = MainFrame_getWindow().create_dialog_window("Map Info", G_CALLBACK(dialog_delete_callback ), &dialog );
+
+ window_set_position( window, g_posMapInfoWnd );
+
+ {
+ auto vbox = create_dialog_vbox( 4, 4 );
+ window.add(vbox);
+
+ {
+ auto hbox = create_dialog_hbox( 4 );
+ vbox.pack_start( hbox, FALSE, TRUE, 0 );
+
+ {
+ auto table = create_dialog_table( 2, 2, 4, 4 );
+ hbox.pack_start( table, TRUE, TRUE, 0 );
+
+ {
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
+ gtk_editable_set_editable( GTK_EDITABLE(entry), FALSE );
+
+ brushes_entry = entry;
+ }
+ {
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
+ gtk_editable_set_editable( GTK_EDITABLE(entry), FALSE );
+
+ entities_entry = entry;
+ }
+ {
+ ui::Widget label = ui::Label( "Total Brushes" );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {GTK_FILL, 0});
+ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
+ }
+ {
+ ui::Widget label = ui::Label( "Total Entities" );
+ label.show();
+ table.attach(label, {0, 1, 1, 2}, {GTK_FILL, 0});
+ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
+ }
+ }
+ {
+ auto vbox2 = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox2, FALSE, FALSE, 0 );
+
+ {
+ auto button = create_dialog_button( "Close", G_CALLBACK( dialog_button_ok ), &dialog );
+ vbox2.pack_start( button, FALSE, FALSE, 0 );
+ }
+ }
+ }
+ {
+ ui::Widget label = ui::Label( "Entity breakdown" );
+ label.show();
+ vbox.pack_start( label, FALSE, TRUE, 0 );
+ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
+ }
+ {
+ auto scr = create_scrolled_window( ui::Policy::NEVER, ui::Policy::AUTOMATIC, 4 );
+ vbox.pack_start( scr, TRUE, TRUE, 0 );
+
+ {
+ auto store = ui::ListStore::from(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING ));
+
+ auto view = ui::TreeView(ui::TreeModel::from(store._handle));
+ gtk_tree_view_set_headers_clickable(view, TRUE );
+
+ {
+ auto renderer = ui::CellRendererText(ui::New);
+ auto column = ui::TreeViewColumn( "Entity", renderer, {{"text", 0}} );
+ gtk_tree_view_append_column(view, column );
+ gtk_tree_view_column_set_sort_column_id( column, 0 );
+ }
+
+ {
+ auto renderer = ui::CellRendererText(ui::New);
+ auto column = ui::TreeViewColumn( "Count", renderer, {{"text", 1}} );
+ gtk_tree_view_append_column(view, column );
+ gtk_tree_view_column_set_sort_column_id( column, 1 );
+ }
+
+ view.show();
+
+ scr.add(view);
+
+ EntityBreakdownWalker = store;
+ }
+ }
+ }
+
+ // Initialize fields
+
+ {
+ EntityBreakdown entitymap;
+ Scene_EntityBreakdown( entitymap );
+
+ for ( EntityBreakdown::iterator i = entitymap.begin(); i != entitymap.end(); ++i )
+ {
+ char tmp[16];
+ sprintf( tmp, "%u", Unsigned( ( *i ).second ) );
+ EntityBreakdownWalker.append(0, (*i).first.c_str(), 1, tmp);
+ }
+ }
+
+ EntityBreakdownWalker.unref();
+
+ char tmp[16];
+ sprintf( tmp, "%u", Unsigned( g_brushCount.get() ) );
+ brushes_entry.text(tmp);
+ sprintf( tmp, "%u", Unsigned( g_entityCount.get() ) );
+ entities_entry.text(tmp);
+
+ modal_dialog_show( window, dialog );
+
+ // save before exit
+ window_get_position( window, g_posMapInfoWnd );
+
+ window.destroy();