#include "autosave.h"
#include "brushmodule.h"
#include "brush.h"
+ #include "patch.h"
+bool g_writeMapComments = true;
+
class NameObserver
{
UniqueNames& m_names;
void DoMapInfo(){
ModalDialog dialog;
- ui::Entry brushes_entry{ui::null};
- ui::Entry entities_entry{ui::null};
++ ui::Widget w_brushes{ui::null};
++ ui::Widget w_patches{ui::null};
++ ui::Widget w_ents{ui::null};
++ ui::Widget w_ents_ingame{ui::null};
++ ui::Widget w_groupents{ui::null};
++ ui::Widget w_groupents_ingame{ui::null};
+
- GtkWidget* w_brushes;
- GtkWidget* w_patches;
- GtkWidget* w_ents;
- GtkWidget* w_ents_ingame;
- GtkWidget* w_groupents;
- GtkWidget* w_groupents_ingame;
-
- GtkListStore* EntityBreakdownWalker;
+ ui::ListStore EntityBreakdownWalker{ui::null};
- GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Map Info", G_CALLBACK( dialog_delete_callback ), &dialog );
+ ui::Window window = MainFrame_getWindow().create_dialog_window("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 ) );
+ auto vbox = create_dialog_vbox( 4, 4 );
+ window.add(vbox);
{
- GtkHBox* hbox = create_dialog_hbox( 4 );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), FALSE, FALSE, 0 );
+ auto hbox = create_dialog_hbox( 4 );
- vbox.pack_start( hbox, FALSE, TRUE, 0 );
++ vbox.pack_start( hbox, FALSE, FALSE, 0 );
{
- auto table = create_dialog_table( 2, 2, 4, 4 );
- GtkTable* table = create_dialog_table( 3, 4, 4, 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
++ auto table = create_dialog_table( 3, 4, 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;
- 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 );
++ auto 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, 0.5 );
}
{
- 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;
- GtkWidget* label = gtk_label_new( "" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 3, 0 );
- gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
++ auto label = ui::Label( "" );
++ label.show();
++ table.attach(label, {1, 2, 0, 1}, {GTK_FILL | GTK_EXPAND, 0}, {3, 0});
+ w_brushes = label;
}
{
- ui::Widget label = ui::Label( "Total Brushes" );
- GtkWidget* label = gtk_label_new( "Total Patches:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
++ auto label = ui::Label( "Total Patches" );
+ label.show();
- table.attach(label, {0, 1, 0, 1}, {GTK_FILL, 0});
++ table.attach(label, {2, 3, 0, 1}, {GTK_FILL, 0});
+ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- ui::Widget label = ui::Label( "Total Entities" );
- GtkWidget* label = gtk_label_new( "" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 3, 4, 0, 1,
- (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 3, 0 );
- gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
++ auto label = ui::Label( "" );
+ label.show();
- table.attach(label, {0, 1, 1, 2}, {GTK_FILL, 0});
++ table.attach(label, {3, 4, 0, 1}, {GTK_FILL, 0}, {3, 0});
+ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
+ w_patches = label;
+ }
+ {
- 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 );
++ auto 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, 0.5 );
+ }
+ {
- GtkWidget* label = gtk_label_new( "" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 3, 0 );
++ auto label = ui::Label( "" );
++ label.show();
++ table.attach(label, {1, 2, 1, 2}, {GTK_FILL | GTK_EXPAND, 0}, {3, 0});
+ gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
+ w_ents = label;
}
- GtkWidget* label = gtk_label_new( "Ingame Entities:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ {
- GtkWidget* label = gtk_label_new( "" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 3, 4, 1, 2,
- (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 3, 0 );
++ auto label = ui::Label( "Ingame Entities:" );
++ label.show();
++ table.attach(label, {2, 3, 1, 2}, {GTK_FILL, 0});
+ gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
+ }
+ {
- GtkWidget* label = gtk_label_new( "Group Entities:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
++ auto label = ui::Label( "" );
++ label.show();
++ table.attach(label, {3, 4, 1, 2}, {GTK_FILL | GTK_EXPAND, 0 }, {3, 0});
+ gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
+ w_ents_ingame = label;
+ }
+ {
- GtkWidget* label = gtk_label_new( "" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 1, 2, 2, 3,
- (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 3, 0 );
++ auto label = ui::Label( "Group Entities:" );
++ label.show();
++ table.attach(label, {0, 1, 2, 3}, {GTK_FILL, 0});
+ gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
+ }
+ {
- GtkWidget* label = gtk_label_new( "Ingame Group Entities:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 2, 3,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
++ auto label = ui::Label( "" );
++ label.show();
++ table.attach(label, {1, 2, 2, 3}, {GTK_FILL | GTK_EXPAND, 0}, {3, 0});
+ gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
+ w_groupents = label;
+ }
+ {
- GtkWidget* label = gtk_label_new( "" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 3, 4, 2, 3,
- (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 3, 0 );
++ auto label = ui::Label( "Ingame Group Entities:" );
++ label.show();
++ table.attach(label, {2, 3, 2, 3}, {GTK_FILL, 0});
+ gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
+ }
+ {
++ auto label = ui::Label( "" );
++ label.show();
++ table.attach(label, {3, 4, 2, 3}, {GTK_FILL | GTK_EXPAND, 0}, {3, 0});
+ gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
+ w_groupents_ingame = label;
+ }
+
}
{
- GtkVBox* vbox2 = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox2 ), FALSE, FALSE, 0 );
+ auto vbox2 = create_dialog_vbox( 4 );
+ hbox.pack_start( 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 );
+ 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" );
- 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.5, 0.5 );
++ 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 );
}
{
- 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 );
+ 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 ));
- GtkListStore* store = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_UINT );
++ auto store = ui::ListStore::from(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_UINT ));
- GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) );
- gtk_tree_view_set_headers_clickable( GTK_TREE_VIEW( view ), TRUE );
+ auto view = ui::TreeView(ui::TreeModel::from(store._handle));
+ gtk_tree_view_set_headers_clickable(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 );
+ 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 );
}
}
}
- g_object_unref( G_OBJECT( EntityBreakdownWalker ) );
+ 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);
+ int n_patches = 0;
+ int n_ents_ingame = 0;
+ int n_groupents = 0;
+ int n_groupents_ingame = 0;
+ Scene_CountStuff( n_patches, n_ents_ingame, n_groupents, n_groupents_ingame );
+ //globalOutputStream() << n_patches << n_ents_ingame << n_groupents << n_groupents_ingame << "\n";
+
+ char *markup;
+
+ markup = g_markup_printf_escaped( "<span style=\"italic\"><b>%u</b></span> ", Unsigned( g_brushCount.get() ) );
+ gtk_label_set_markup( GTK_LABEL( w_brushes ), markup );
+ g_free( markup );
+
+ markup = g_markup_printf_escaped( "<span style=\"italic\"><b>%i</b></span> ", n_patches );
+ gtk_label_set_markup( GTK_LABEL( w_patches ), markup );
+ g_free( markup );
+
+ markup = g_markup_printf_escaped( "<span style=\"italic\"><b>%u</b></span> ", Unsigned( g_entityCount.get() ) );
+ gtk_label_set_markup( GTK_LABEL( w_ents ), markup );
+ g_free( markup );
+
+ markup = g_markup_printf_escaped( "<span style=\"italic\"><b>%i</b></span> ", n_ents_ingame );
+ gtk_label_set_markup( GTK_LABEL( w_ents_ingame ), markup );
+ g_free( markup );
+
+ markup = g_markup_printf_escaped( "<span style=\"italic\"><b>%i</b></span> ", n_groupents );
+ gtk_label_set_markup( GTK_LABEL( w_groupents ), markup );
+ g_free( markup );
+
+ markup = g_markup_printf_escaped( "<span style=\"italic\"><b>%i</b></span> ", n_groupents_ingame );
+ gtk_label_set_markup( GTK_LABEL( w_groupents_ingame ), markup );
+ g_free( markup );
+
+
modal_dialog_show( window, dialog );
// save before exit