]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - contrib/prtview/LoadPortalFileDialog.cpp
- Disabled useless "deprecated" warnings when using stdc functions
[xonotic/netradiant.git] / contrib / prtview / LoadPortalFileDialog.cpp
index 13d780cdf1e78af1a33a06a9414ba3f49a7143a9..d9984a0b8a7b66f935feedc5f67247a643855f95 100644 (file)
@@ -20,15 +20,18 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 // 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"
 
-#ifdef GTK_PLUGIN
+#include "qerplugin.h"
+
+#include "prtview.h"
+#include "portals.h"
 
 static void dialog_button_callback (GtkWidget *widget, gpointer data)
 {
@@ -40,7 +43,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)
@@ -65,7 +68,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)));
 }
 
@@ -165,14 +168,16 @@ int DoLoadPortalFileDialog ()
                      GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
   gtk_widget_set_usize (button, 60, -2);
 
-  strcpy (portals.fn, g_FuncTable.m_pfnGetMapName());
+  strcpy (portals.fn, GlobalRadiant().getMapName());
   char* fn = strrchr (portals.fn, '.');
   if (fn != NULL)
   {
     strcpy(fn, ".prt");
   }
 
-  gtk_entry_set_text (GTK_ENTRY (entry), portals.fn);
+  StringOutputStream value(256);
+  value << ConvertLocaleToUTF8(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);
 
@@ -186,8 +191,8 @@ int DoLoadPortalFileDialog ()
   {
     portals.Purge();
 
-    portals.show_3d = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check3d)) ? qtrue : qfalse;
-    portals.show_2d = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check2d)) ? qtrue : qfalse;
+    portals.show_3d = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check3d)) ? true : false;
+    portals.show_2d = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check2d)) ? true : false;
   }
 
   gtk_grab_remove (dlg);
@@ -195,92 +200,3 @@ int DoLoadPortalFileDialog ()
 
   return ret;
 }
-
-#else // GTK_PLUGIN
-
-/////////////////////////////////////////////////////////////////////////////
-// CLoadPortalFileDialog dialog
-
-CLoadPortalFileDialog::CLoadPortalFileDialog(CWnd* pParent /*=NULL*/)
-       : CDialog(CLoadPortalFileDialog::IDD, pParent)
-{
-       //{{AFX_DATA_INIT(CLoadPortalFileDialog)
-               // NOTE: the ClassWizard will add member initialization here
-       //}}AFX_DATA_INIT
-}
-
-
-void CLoadPortalFileDialog::DoDataExchange(CDataExchange* pDX)
-{
-       CDialog::DoDataExchange(pDX);
-       //{{AFX_DATA_MAP(CLoadPortalFileDialog)
-       DDX_Control(pDX, IDC_LOAD_3D, m_3d_ctrl);
-       DDX_Control(pDX, IDC_LOAD_2D, m_2d_ctrl);
-       DDX_Control(pDX, IDC_LOAD_FILE_NAME, m_fn_ctrl);
-       //}}AFX_DATA_MAP
-}
-
-
-BEGIN_MESSAGE_MAP(CLoadPortalFileDialog, CDialog)
-       //{{AFX_MSG_MAP(CLoadPortalFileDialog)
-       ON_BN_CLICKED(IDC_LOAD_OTHER, OnLoadOther)
-       //}}AFX_MSG_MAP
-END_MESSAGE_MAP()
-
-
-/////////////////////////////////////////////////////////////////////////////
-// CLoadPortalFileDialog message handlers
-
-bool CLoadPortalFileDialog::OnInitDialog() 
-{
-       CDialog::OnInitDialog();
-
-       char fn_drive[_MAX_DRIVE];
-       char fn_dir[_MAX_DIR];
-       char fn_name[_MAX_FNAME];
-       char fn_ext[_MAX_EXT];
-
-       char *fn = g_IBSPTable.m_pfnGetMapName();
-
-       _fullpath(portals.fn, fn, _MAX_PATH);
-       _splitpath(fn, fn_drive, fn_dir, fn_name, fn_ext);
-
-       strcpy(portals.fn, fn_drive);
-       strcat(portals.fn, fn_dir);
-       strcat(portals.fn, fn_name);
-       strcat(portals.fn, ".prt");
-
-       m_fn_ctrl.SetWindowText(portals.fn);
-
-       m_2d_ctrl.SetCheck(portals.show_2d);
-       m_3d_ctrl.SetCheck(portals.show_3d);
-
-       return true;  // return TRUE unless you set the focus to a control
-                     // EXCEPTION: OCX Property Pages should return FALSE
-}
-
-void CLoadPortalFileDialog::OnOK() 
-{
-       portals.Purge();
-
-       portals.show_3d = m_3d_ctrl.GetCheck();
-       portals.show_2d = m_2d_ctrl.GetCheck();
-       
-       CDialog::OnOK();
-}
-
-void CLoadPortalFileDialog::OnLoadOther() 
-{
-       CFileDialog dlg(TRUE, "prt", portals.fn, OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_LONGNAMES | OFN_FILEMUSTEXIST,
-               "Portal files (*.prt)|*.prt|All Files (*.*)|*.*||", NULL);
-
-       dlg.m_ofn.lpstrTitle = "Locate portal file";
-
-       if(IDOK == dlg.DoModal())
-       {
-               _fullpath(portals.fn, dlg.GetPathName().GetBuffer(1), _MAX_PATH);
-               m_fn_ctrl.SetWindowText(portals.fn);
-       }
-}
-
-#endif // GTK_PLUGIN