]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/map.cpp
radiant/q3map2: add option to disable engine path and home path
[xonotic/netradiant.git] / radiant / map.cpp
index 8da8654457fd5c972f574dcd7fc39278a530df28..5c91dfad8e183cec87712f376b31d2cf48dd2998 100644 (file)
@@ -124,7 +124,7 @@ void nameChanged( const char* name ){
        m_name = name;
        construct();
 }
-typedef MemberCaller1<NameObserver, const char*, &NameObserver::nameChanged> NameChangedCaller;
+typedef MemberCaller<NameObserver, void(const char*), &NameObserver::nameChanged> NameChangedCaller;
 };
 
 class BasicNamespace : public Namespace
@@ -786,9 +786,7 @@ void DoMapInfo(){
                                {
                                        auto entry = ui::Entry(ui::New);
                                        entry.show();
-                                       gtk_table_attach( table, entry , 1, 2, 0, 1,
-                                                                         (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table.attach(entry, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
                                        gtk_editable_set_editable( GTK_EDITABLE(entry), FALSE );
 
                                        brushes_entry = entry;
@@ -796,9 +794,7 @@ void DoMapInfo(){
                                {
                                        auto entry = ui::Entry(ui::New);
                                        entry.show();
-                                       gtk_table_attach( table, entry , 1, 2, 1, 2,
-                                                                         (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
                                        gtk_editable_set_editable( GTK_EDITABLE(entry), FALSE );
 
                                        entities_entry = entry;
@@ -806,17 +802,13 @@ void DoMapInfo(){
                                {
                                        ui::Widget label = ui::Label( "Total Brushes" );
                                        label.show();
-                                       gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1,
-                                                                         (GtkAttachOptions) ( GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    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();
-                                       gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2,
-                                                                         (GtkAttachOptions) ( GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table.attach(label, {0, 1, 1, 2}, {GTK_FILL, 0});
                                        gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
                                }
                        }
@@ -841,22 +833,22 @@ void DoMapInfo(){
                        vbox.pack_start( scr, TRUE, TRUE, 0 );
 
                        {
-                               ui::ListStore store = ui::ListStore(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING ));
+                               auto store = ui::ListStore::from(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING ));
 
-                               ui::Widget view = ui::TreeView(ui::TreeModel( 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 );
 
                                {
                                        auto renderer = ui::CellRendererText(ui::New);
-                                       GtkTreeViewColumn* column = ui::TreeViewColumn( "Entity", renderer, {{"text", 0}} );
-                                       gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
+                                       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);
-                                       GtkTreeViewColumn* column = ui::TreeViewColumn( "Count", renderer, {{"text", 1}} );
-                                       gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
+                                       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 );
                                }
 
@@ -1548,7 +1540,27 @@ tryDecompile:
                output.push_string( EnginePath_get() );
                output.push_string( "\" -fs_homepath \"" );
                output.push_string( g_qeglobals.m_userEnginePath.c_str() );
-               output.push_string( "\" -fs_game " );
+               output.push_string( "\"" );
+
+               // extra pakpaths
+               for ( int i = 0; i < g_pakPathCount; i++ ) {
+                       if ( g_strcmp0( g_strPakPath[i].c_str(), "") ) {
+                               output.push_string( " -fs_pakpath \"" );
+                               output.push_string( g_strPakPath[i].c_str() );
+                               output.push_string( "\"" );
+                       }
+               }
+
+               // extra switches
+               if ( g_disableEnginePath ) {
+                       output.push_string( " -fs_nobasepath " );
+               }
+
+               if ( g_disableHomePath ) {
+                       output.push_string( " -fs_nohomepath " );
+               }
+
+               output.push_string( " -fs_game " );
                output.push_string( gamename_get() );
                output.push_string( " -convert -format " );
                output.push_string( Brush::m_type == eBrushTypeQuake3BP ? "map_bp" : "map" );
@@ -1796,7 +1808,7 @@ const char* getMapsPath(){
 
 const char* getLastFolderPath(){
        if (g_strLastFolder.empty()) {
-               GlobalPreferenceSystem().registerPreference( "LastFolder", CopiedStringImportStringCaller( g_strLastFolder ), CopiedStringExportStringCaller( g_strLastFolder ) );
+               GlobalPreferenceSystem().registerPreference( "LastFolder", make_property_string( g_strLastFolder ) );
                if (g_strLastFolder.empty()) {
                        g_strLastFolder = g_qeglobals.m_userGamePath;
                }
@@ -2051,32 +2063,24 @@ void DoFind(){
                        {
                                ui::Widget label = ui::Label( "Entity number" );
                                label.show();
-                               gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1,
-                                                                 (GtkAttachOptions) ( 0 ),
-                                                                 (GtkAttachOptions) ( 0 ), 0, 0 );
+                (table).attach(label, {0, 1, 0, 1}, {0, 0});
                        }
                        {
                                ui::Widget label = ui::Label( "Brush number" );
                                label.show();
-                               gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2,
-                                                                 (GtkAttachOptions) ( 0 ),
-                                                                 (GtkAttachOptions) ( 0 ), 0, 0 );
+                (table).attach(label, {0, 1, 1, 2}, {0, 0});
                        }
                        {
                                auto entry = ui::Entry(ui::New);
                                entry.show();
-                               gtk_table_attach( table, entry , 1, 2, 0, 1,
-                                                                 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
-                                                                 (GtkAttachOptions) ( 0 ), 0, 0 );
+                table.attach(entry, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
                                gtk_widget_grab_focus( entry  );
                                entity = entry;
                        }
                        {
                                auto entry = ui::Entry(ui::New);
                                entry.show();
-                               gtk_table_attach( table, entry , 1, 2, 1, 2,
-                                                                 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
-                                                                 (GtkAttachOptions) ( 0 ), 0, 0 );
+                table.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
 
                                brush = entry;
                        }
@@ -2177,16 +2181,16 @@ CopiedString g_strLastMap;
 bool g_bLoadLastMap = false;
 
 void Map_Construct(){
-       GlobalCommands_insert( "RegionOff", FreeCaller<RegionOff>() );
-       GlobalCommands_insert( "RegionSetXY", FreeCaller<RegionXY>() );
-       GlobalCommands_insert( "RegionSetBrush", FreeCaller<RegionBrush>() );
-       GlobalCommands_insert( "RegionSetSelection", FreeCaller<RegionSelected>(), Accelerator( 'R', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+       GlobalCommands_insert( "RegionOff", makeCallbackF(RegionOff) );
+       GlobalCommands_insert( "RegionSetXY", makeCallbackF(RegionXY) );
+       GlobalCommands_insert( "RegionSetBrush", makeCallbackF(RegionBrush) );
+       GlobalCommands_insert( "RegionSetSelection", makeCallbackF(RegionSelected), Accelerator( 'R', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
 
-       GlobalPreferenceSystem().registerPreference( "LastMap", CopiedStringImportStringCaller( g_strLastMap ), CopiedStringExportStringCaller( g_strLastMap ) );
-       GlobalPreferenceSystem().registerPreference( "LoadLastMap", BoolImportStringCaller( g_bLoadLastMap ), BoolExportStringCaller( g_bLoadLastMap ) );
-       GlobalPreferenceSystem().registerPreference( "MapInfoDlg", WindowPositionImportStringCaller( g_posMapInfoWnd ), WindowPositionExportStringCaller( g_posMapInfoWnd ) );
+       GlobalPreferenceSystem().registerPreference( "LastMap", make_property_string( g_strLastMap ) );
+       GlobalPreferenceSystem().registerPreference( "LoadLastMap", make_property_string( g_bLoadLastMap ) );
+       GlobalPreferenceSystem().registerPreference( "MapInfoDlg", make_property<WindowPosition_String>( g_posMapInfoWnd ) );
 
-       PreferencesDialog_addSettingsPreferences( FreeCaller1<PreferencesPage&, Map_constructPreferences>() );
+       PreferencesDialog_addSettingsPreferences( makeCallbackF(Map_constructPreferences) );
 
        GlobalEntityClassManager().attach( g_MapEntityClasses );
        Radiant_attachHomePathsObserver( g_MapModuleObserver );