ported PrtView plugin

git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@40 8a3a26a2-13c4-0310-b231-cf6edde360e5
This commit is contained in:
spog
2006-03-26 03:13:17 +00:00
parent 0819a13b05
commit 08d558e1a4
50 changed files with 1205 additions and 3100 deletions

View File

@@ -20,15 +20,16 @@ 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 "stream/stringstream.h"
#include "convert.h"
#ifdef GTK_PLUGIN
#include "qerplugin.h"
#include "PrtView.h"
#include "Portals.h"
static void dialog_button_callback (GtkWidget *widget, gpointer data)
{
@@ -165,14 +166,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 +189,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 +198,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