]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - contrib/prtview/LoadPortalFileDialog.cpp
Merge remote-tracking branch 'ttimo/master'
[xonotic/netradiant.git] / contrib / prtview / LoadPortalFileDialog.cpp
index bd0439e38313406c0fa406781f04d3914a02c1c7..f3d4df8d06a0104867dd8d1b259e9d9b168a1016 100644 (file)
 // LoadPortalFileDialog.cpp : implementation file
 //
 
-#include "stdafx.h"
+#include "LoadPortalFileDialog.h"
 
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-//static char THIS_FILE[] = __FILE__;
-#endif
+#include <gtk/gtk.h>
+#include <gtkutil/pointer.h>
+#include "stream/stringstream.h"
+#include "convert.h"
+#include "gtkutil/pointer.h"
+
+#include "qerplugin.h"
+
+#include "prtview.h"
+#include "portals.h"
 
 static void dialog_button_callback( GtkWidget *widget, gpointer data ){
        GtkWidget *parent;
@@ -37,7 +42,7 @@ static void dialog_button_callback( GtkWidget *widget, gpointer data ){
        ret = (int*)g_object_get_data( G_OBJECT( parent ), "ret" );
 
        *loop = 0;
-       *ret = (int)data;
+       *ret = gpointer_to_int( data );
 }
 
 static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer data ){
@@ -60,7 +65,7 @@ static void file_sel_callback( GtkWidget *widget, gpointer data ){
        filename = (char**)g_object_get_data( G_OBJECT( parent ), "filename" );
 
        *loop = 0;
-       if ( (int)data == IDOK ) {
+       if ( gpointer_to_int( data ) == IDOK ) {
                *filename = g_strdup( gtk_file_selection_get_filename( GTK_FILE_SELECTION( parent ) ) );
        }
 }
@@ -158,15 +163,15 @@ int DoLoadPortalFileDialog(){
                                                GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) );
        gtk_widget_set_usize( button, 60, -2 );
 
-       char *fn = g_FuncTable.m_pfnGetMapName();
-       strcpy( portals.fn, fn );
-       fn = strrchr( portals.fn, '.' );
+       strcpy( portals.fn, GlobalRadiant().getMapName() );
+       char* fn = strrchr( portals.fn, '.' );
        if ( fn != NULL ) {
-               *fn = '\0';
-               strcat( portals.fn, ".prt" );
+               strcpy( fn, ".prt" );
        }
 
-       gtk_entry_set_text( GTK_ENTRY( entry ), portals.fn );
+       StringOutputStream value( 256 );
+       value << portals.fn;
+       gtk_entry_set_text( GTK_ENTRY( entry ), value.c_str() );
        gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( check2d ), portals.show_2d );
        gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( check3d ), portals.show_3d );