The GtkRadiant sources as originally released under the GPL license.

This commit is contained in:
Travis Bradshaw
2012-01-31 15:20:35 -06:00
commit 0991a5ce8b
1590 changed files with 431941 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
Debug
Release
*.d
*.plg
*.BAK
*.mak
*.ncb
*.opt

View File

@@ -0,0 +1,139 @@
/*
PrtView plugin for GtkRadiant
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// AboutDialog.cpp : implementation file
//
#include "stdafx.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
//static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDialog dialog
#ifdef GTK_PLUGIN
static void dialog_button_callback (GtkWidget *widget, gpointer data)
{
GtkWidget *parent;
int *loop, *ret;
parent = gtk_widget_get_toplevel (widget);
loop = (int*)g_object_get_data (G_OBJECT (parent), "loop");
ret = (int*)g_object_get_data (G_OBJECT (parent), "ret");
*loop = 0;
*ret = (int)data;
}
static gint dialog_delete_callback (GtkWidget *widget, GdkEvent* event, gpointer data)
{
int *loop;
gtk_widget_hide (widget);
loop = (int*)g_object_get_data (G_OBJECT (widget), "loop");
*loop = 0;
return TRUE;
}
void DoAboutDlg ()
{
GtkWidget *dlg, *hbox, *vbox, *button, *label;
int loop = 1, ret = IDCANCEL;
dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (dlg), "About Portal Viewer");
gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
g_object_set_data (G_OBJECT (dlg), "loop", &loop);
g_object_set_data (G_OBJECT (dlg), "ret", &ret);
hbox = gtk_hbox_new (FALSE, 10);
gtk_widget_show (hbox);
gtk_container_add (GTK_CONTAINER (dlg), hbox);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 10);
label = gtk_label_new ("Version 1.000\n\n"
"Gtk port by Leonardo Zide\nleo@lokigames.com\n\n"
"Written by Geoffrey DeWan\ngdewan@prairienet.org\n\n"
"Built against GtkRadiant " RADIANT_VERSION "\n"
__DATE__
);
gtk_widget_show (label);
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
vbox = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox);
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("OK");
gtk_widget_show (button);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
gtk_widget_set_usize (button, 60, -2);
gtk_grab_add (dlg);
gtk_widget_show (dlg);
while (loop)
gtk_main_iteration ();
gtk_grab_remove (dlg);
gtk_widget_destroy (dlg);
}
#else // GTK_PLUGIN
CAboutDialog::CAboutDialog(CWnd* pParent /*=NULL*/)
: CDialog(CAboutDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CAboutDialog)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CAboutDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDialog)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDialog, CDialog)
//{{AFX_MSG_MAP(CAboutDialog)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // GTK_PLUGIN
/////////////////////////////////////////////////////////////////////////////
// CAboutDialog message handlers

View File

@@ -0,0 +1,72 @@
/*
PrtView plugin for GtkRadiant
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#if !defined(AFX_ABOUTDIALOG_H__FA3BE6A2_1F1F_11D4_BFF1_204C4F4F5020__INCLUDED_)
#define AFX_ABOUTDIALOG_H__FA3BE6A2_1F1F_11D4_BFF1_204C4F4F5020__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// AboutDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CAboutDialog dialog
#ifdef GTK_PLUGIN
void DoAboutDlg ();
#else // GTK_PLUGIN
class CAboutDialog : public CDialog
{
// Construction
public:
CAboutDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CAboutDialog)
enum { IDD = IDD_ABOUT };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CAboutDialog)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#endif // GTK_PLUGIN
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_ABOUTDIALOG_H__FA3BE6A2_1F1F_11D4_BFF1_204C4F4F5020__INCLUDED_)

View File

@@ -0,0 +1,925 @@
/*
PrtView plugin for GtkRadiant
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// ConfigDialog.cpp : implementation file
//
#include "stdafx.h"
#include <stdio.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
//static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CConfigDialog dialog
#ifdef GTK_PLUGIN
static void dialog_button_callback (GtkWidget *widget, gpointer data)
{
GtkWidget *parent;
int *loop, *ret;
parent = gtk_widget_get_toplevel (widget);
loop = (int*)g_object_get_data (G_OBJECT (parent), "loop");
ret = (int*)g_object_get_data (G_OBJECT (parent), "ret");
*loop = 0;
*ret = (int)data;
}
static gint dialog_delete_callback (GtkWidget *widget, GdkEvent* event, gpointer data)
{
int *loop;
gtk_widget_hide (widget);
loop = (int*)g_object_get_data (G_OBJECT (widget), "loop");
*loop = 0;
return TRUE;
}
// =============================================================================
// Color selection dialog
static int DoColor (COLORREF *c)
{
GtkWidget* dlg;
double clr[3];
int loop = 1, ret = IDCANCEL;
clr[0] = ((double)GetRValue (*c)) / 255.0;
clr[1] = ((double)GetGValue (*c)) / 255.0;
clr[2] = ((double)GetBValue (*c)) / 255.0;
dlg = gtk_color_selection_dialog_new ("Choose Color");
gtk_color_selection_set_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (dlg)->colorsel), clr);
gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
gtk_signal_connect (GTK_OBJECT (GTK_COLOR_SELECTION_DIALOG (dlg)->ok_button), "clicked",
GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
gtk_signal_connect (GTK_OBJECT (GTK_COLOR_SELECTION_DIALOG (dlg)->cancel_button), "clicked",
GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
g_object_set_data (G_OBJECT (dlg), "loop", &loop);
g_object_set_data (G_OBJECT (dlg), "ret", &ret);
gtk_widget_show(dlg);
gtk_grab_add(dlg);
while (loop)
gtk_main_iteration ();
gtk_color_selection_get_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (dlg)->colorsel), clr);
gtk_grab_remove (dlg);
gtk_widget_destroy (dlg);
if (ret == IDOK)
{
*c = RGB (clr[0]*255, clr[1]*255, clr[2]*255);
}
return ret;
}
static void Set2DText (GtkWidget* label)
{
char s[40];
sprintf(s, "Line Width = %6.3f", portals.width_2d * 0.5f);
gtk_label_set_text (GTK_LABEL (label), s);
}
static void Set3DText (GtkWidget* label)
{
char s[40];
sprintf(s, "Line Width = %6.3f", portals.width_3d * 0.5f);
gtk_label_set_text (GTK_LABEL (label), s);
}
static void Set3DTransText (GtkWidget* label)
{
char s[40];
sprintf(s, "Polygon transparency = %d%%", (int)portals.trans_3d);
gtk_label_set_text (GTK_LABEL (label), s);
}
static void SetClipText (GtkWidget* label)
{
char s[40];
sprintf(s, "Cubic clip range = %d", (int)portals.clip_range * 64);
gtk_label_set_text (GTK_LABEL (label), s);
}
static void OnScroll2d (GtkAdjustment *adj, gpointer data)
{
portals.width_2d = static_cast<float>(adj->value);
Set2DText (GTK_WIDGET (data));
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_2D);
}
static void OnScroll3d (GtkAdjustment *adj, gpointer data)
{
portals.width_3d = static_cast<float>(adj->value);
Set3DText (GTK_WIDGET (data));
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
static void OnScrollTrans (GtkAdjustment *adj, gpointer data)
{
portals.trans_3d = static_cast<float>(adj->value);
Set3DTransText (GTK_WIDGET (data));
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
static void OnScrollClip (GtkAdjustment *adj, gpointer data)
{
portals.clip_range = static_cast<float>(adj->value);
SetClipText (GTK_WIDGET (data));
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
static void OnAntiAlias2d (GtkWidget *widget, gpointer data)
{
portals.aa_2d = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) ? qtrue : qfalse;
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_2D);
}
static void OnConfig2d (GtkWidget *widget, gpointer data)
{
portals.show_2d = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) ? qtrue : qfalse;
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_2D);
}
static void OnColor2d (GtkWidget *widget, gpointer data)
{
if (DoColor (&portals.color_2d) == IDOK)
{
portals.FixColors();
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_2D);
}
}
static void OnConfig3d (GtkWidget *widget, gpointer data)
{
portals.show_3d = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) ? qtrue : qfalse;
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
static void OnAntiAlias3d (GtkWidget *widget, gpointer data)
{
portals.aa_3d = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) ? qtrue : qfalse;
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
static void OnColor3d (GtkWidget *widget, gpointer data)
{
if (DoColor (&portals.color_3d) == IDOK)
{
portals.FixColors();
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
}
static void OnColorFog (GtkWidget *widget, gpointer data)
{
if (DoColor (&portals.color_fog) == IDOK)
{
portals.FixColors();
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
}
static void OnFog (GtkWidget *widget, gpointer data)
{
portals.fog = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) ? qtrue : qfalse;
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
static void OnSelchangeZbuffer (GtkWidget *widget, gpointer data)
{
portals.zbuffer = GPOINTER_TO_INT (data);
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
static void OnPoly (GtkWidget *widget, gpointer data)
{
portals.polygons = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
static void OnLines (GtkWidget *widget, gpointer data)
{
portals.lines = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
static void OnClip (GtkWidget *widget, gpointer data)
{
portals.clip = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) ? qtrue : qfalse;
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
void DoConfigDialog ()
{
GtkWidget *dlg, *hbox, *vbox, *vbox2, *button, *table, *frame;
GtkWidget *lw3slider, *lw3label, *lw2slider, *lw2label, *zlist, *menu, *item;
GtkWidget *aa2check, *aa3check, *depthcheck, *linescheck, *polyscheck;
GtkWidget *transslider, *translabel, *clipslider, *cliplabel;
GtkWidget *show2check, *show3check, *portalcheck;
int loop = 1, ret = IDCANCEL;
GtkObject *adj;
dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (dlg), "Portal Viewer Configuration");
gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
g_object_set_data (G_OBJECT (dlg), "loop", &loop);
g_object_set_data (G_OBJECT (dlg), "ret", &ret);
vbox = gtk_vbox_new (FALSE, 5);
gtk_widget_show (vbox);
gtk_container_add (GTK_CONTAINER (dlg), vbox);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
frame = gtk_frame_new ("3D View");
gtk_widget_show (frame);
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
vbox2 = gtk_vbox_new (FALSE, 5);
gtk_widget_show (vbox2);
gtk_container_add (GTK_CONTAINER (frame), vbox2);
gtk_container_set_border_width (GTK_CONTAINER (vbox2), 5);
hbox = gtk_hbox_new (FALSE, 5);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (vbox2), hbox, TRUE, TRUE, 0);
adj = gtk_adjustment_new (portals.width_3d, 2, 40, 1, 1, 1);
lw3slider = gtk_hscale_new (GTK_ADJUSTMENT (adj));
gtk_widget_show (lw3slider);
gtk_box_pack_start (GTK_BOX (hbox), lw3slider, TRUE, TRUE, 0);
gtk_scale_set_draw_value (GTK_SCALE (lw3slider), FALSE);
lw3label = gtk_label_new ("");
gtk_widget_show (lw3label);
gtk_box_pack_start (GTK_BOX (hbox), lw3label, FALSE, TRUE, 0);
gtk_signal_connect (adj, "value_changed", GTK_SIGNAL_FUNC (OnScroll3d), lw3label);
table = gtk_table_new (2, 4, FALSE);
gtk_widget_show (table);
gtk_box_pack_start (GTK_BOX (vbox2), table, TRUE, TRUE, 0);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
button = gtk_button_new_with_label ("Color");
gtk_widget_show (button);
gtk_table_attach (GTK_TABLE (table), button, 0, 1, 0, 1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (OnColor3d), NULL);
button = gtk_button_new_with_label ("Depth Color");
gtk_widget_show (button);
gtk_table_attach (GTK_TABLE (table), button, 0, 1, 1, 2,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (OnColorFog), NULL);
aa3check = gtk_check_button_new_with_label ("Anti-Alias (May not work on some video cards)");
gtk_widget_show (aa3check);
gtk_table_attach (GTK_TABLE (table), aa3check, 1, 4, 0, 1,
(GtkAttachOptions) (GTK_EXPAND|GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_signal_connect (GTK_OBJECT (aa3check), "toggled", GTK_SIGNAL_FUNC (OnAntiAlias3d), NULL);
depthcheck = gtk_check_button_new_with_label ("Depth Cue");
gtk_widget_show (depthcheck);
gtk_table_attach (GTK_TABLE (table), depthcheck, 1, 2, 1, 2,
(GtkAttachOptions) (GTK_EXPAND|GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_signal_connect (GTK_OBJECT (depthcheck), "toggled", GTK_SIGNAL_FUNC (OnFog), NULL);
linescheck = gtk_check_button_new_with_label ("Lines");
gtk_widget_show (linescheck);
gtk_table_attach (GTK_TABLE (table), linescheck, 2, 3, 1, 2,
(GtkAttachOptions) (GTK_EXPAND|GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_signal_connect (GTK_OBJECT (linescheck), "toggled", GTK_SIGNAL_FUNC (OnLines), NULL);
polyscheck = gtk_check_button_new_with_label ("Polygons");
gtk_widget_show (polyscheck);
gtk_table_attach (GTK_TABLE (table), polyscheck, 3, 4, 1, 2,
(GtkAttachOptions) (GTK_EXPAND|GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_signal_connect (GTK_OBJECT (polyscheck), "toggled", GTK_SIGNAL_FUNC (OnPoly), NULL);
zlist = gtk_option_menu_new ();
gtk_widget_show (zlist);
gtk_box_pack_start (GTK_BOX (vbox2), zlist, TRUE, FALSE, 0);
menu = gtk_menu_new ();
gtk_widget_show (menu);
gtk_option_menu_set_menu (GTK_OPTION_MENU (zlist), menu);
item = gtk_menu_item_new_with_label ("Z-Buffer Test and Write (recommended for solid or no polygons)");
gtk_widget_show (item);
gtk_signal_connect (GTK_OBJECT (item), "activate",
GTK_SIGNAL_FUNC (OnSelchangeZbuffer), GINT_TO_POINTER (0));
gtk_menu_append (GTK_MENU (menu), item);
item = gtk_menu_item_new_with_label ("Z-Buffer Test Only (recommended for transparent polygons)");
gtk_widget_show (item);
gtk_signal_connect (GTK_OBJECT (item), "activate",
GTK_SIGNAL_FUNC (OnSelchangeZbuffer), GINT_TO_POINTER (1));
gtk_menu_append (GTK_MENU (menu), item);
item = gtk_menu_item_new_with_label ("Z-Buffer Off");
gtk_widget_show (item);
gtk_signal_connect (GTK_OBJECT (item), "activate",
GTK_SIGNAL_FUNC (OnSelchangeZbuffer), GINT_TO_POINTER (2));
gtk_menu_append (GTK_MENU (menu), item);
table = gtk_table_new (2, 2, FALSE);
gtk_widget_show (table);
gtk_box_pack_start (GTK_BOX (vbox2), table, TRUE, TRUE, 0);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
adj = gtk_adjustment_new (portals.trans_3d, 0, 100, 1, 1, 1);
transslider = gtk_hscale_new (GTK_ADJUSTMENT (adj));
gtk_widget_show (transslider);
gtk_table_attach (GTK_TABLE (table), transslider, 0, 1, 0, 1,
(GtkAttachOptions) (GTK_EXPAND|GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_scale_set_draw_value (GTK_SCALE (transslider), FALSE);
translabel = gtk_label_new ("");
gtk_widget_show (translabel);
gtk_table_attach (GTK_TABLE (table), translabel, 1, 2, 0, 1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment (GTK_MISC (translabel), 0.0, 0.0);
gtk_signal_connect (adj, "value_changed", GTK_SIGNAL_FUNC (OnScrollTrans), translabel);
adj = gtk_adjustment_new (portals.clip_range, 1, 128, 1, 1, 1);
clipslider = gtk_hscale_new (GTK_ADJUSTMENT (adj));
gtk_widget_show (clipslider);
gtk_table_attach (GTK_TABLE (table), clipslider, 0, 1, 1, 2,
(GtkAttachOptions) (GTK_EXPAND|GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_scale_set_draw_value (GTK_SCALE (clipslider), FALSE);
cliplabel = gtk_label_new ("");
gtk_widget_show (cliplabel);
gtk_table_attach (GTK_TABLE (table), cliplabel, 1, 2, 1, 2,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment (GTK_MISC (cliplabel), 0.0, 0.0);
gtk_signal_connect (adj, "value_changed", GTK_SIGNAL_FUNC (OnScrollClip), cliplabel);
hbox = gtk_hbox_new (TRUE, 5);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (vbox2), hbox, TRUE, FALSE, 0);
show3check = gtk_check_button_new_with_label ("Show");
gtk_widget_show (show3check);
gtk_box_pack_start (GTK_BOX (hbox), show3check, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (show3check), "toggled", GTK_SIGNAL_FUNC (OnConfig3d), NULL);
portalcheck = gtk_check_button_new_with_label ("Portal cubic clipper");
gtk_widget_show (portalcheck);
gtk_box_pack_start (GTK_BOX (hbox), portalcheck, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (portalcheck), "toggled", GTK_SIGNAL_FUNC (OnClip), NULL);
frame = gtk_frame_new ("2D View");
gtk_widget_show (frame);
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
vbox2 = gtk_vbox_new (FALSE, 5);
gtk_widget_show (vbox2);
gtk_container_add (GTK_CONTAINER (frame), vbox2);
gtk_container_set_border_width (GTK_CONTAINER (vbox2), 5);
hbox = gtk_hbox_new (FALSE, 5);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (vbox2), hbox, TRUE, FALSE, 0);
adj = gtk_adjustment_new (portals.width_2d, 2, 40, 1, 1, 1);
lw2slider = gtk_hscale_new (GTK_ADJUSTMENT (adj));
gtk_widget_show (lw2slider);
gtk_box_pack_start (GTK_BOX (hbox), lw2slider, TRUE, TRUE, 0);
gtk_scale_set_draw_value (GTK_SCALE (lw2slider), FALSE);
lw2label = gtk_label_new ("");
gtk_widget_show (lw2label);
gtk_box_pack_start (GTK_BOX (hbox), lw2label, FALSE, TRUE, 0);
gtk_signal_connect (adj, "value_changed", GTK_SIGNAL_FUNC (OnScroll2d), lw2label);
hbox = gtk_hbox_new (FALSE, 5);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (vbox2), hbox, TRUE, FALSE, 0);
button = gtk_button_new_with_label ("Color");
gtk_widget_show (button);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (OnColor2d), NULL);
gtk_widget_set_usize (button, 60, -2);
aa2check = gtk_check_button_new_with_label ("Anti-Alias (May not work on some video cards)");
gtk_widget_show (aa2check);
gtk_box_pack_start (GTK_BOX (hbox), aa2check, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (aa2check), "toggled", GTK_SIGNAL_FUNC (OnAntiAlias2d), NULL);
hbox = gtk_hbox_new (FALSE, 5);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (vbox2), hbox, TRUE, FALSE, 0);
show2check = gtk_check_button_new_with_label ("Show");
gtk_widget_show (show2check);
gtk_box_pack_start (GTK_BOX (hbox), show2check, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (show2check), "toggled", GTK_SIGNAL_FUNC (OnConfig2d), NULL);
hbox = gtk_hbox_new (FALSE, 5);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("OK");
gtk_widget_show (button);
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
gtk_widget_set_usize (button, 60, -2);
// initialize dialog
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (show2check), portals.show_2d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (aa2check), portals.aa_2d);
Set2DText (lw2label);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (show3check), portals.show_3d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (depthcheck), portals.fog);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (polyscheck), portals.polygons);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (linescheck), portals.lines);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (aa3check), portals.aa_3d);
gtk_option_menu_set_history (GTK_OPTION_MENU (zlist), portals.zbuffer);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (portalcheck), portals.clip);
Set3DText (lw3label);
Set3DTransText (translabel);
SetClipText (cliplabel);
gtk_grab_add (dlg);
gtk_widget_show (dlg);
while (loop)
gtk_main_iteration ();
gtk_grab_remove (dlg);
gtk_widget_destroy (dlg);
}
#else // GTK_PLUGIN
CConfigDialog::CConfigDialog(CWnd* pParent /*=NULL*/)
: CDialog(CConfigDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CConfigDialog)
//}}AFX_DATA_INIT
}
void CConfigDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CConfigDialog)
DDX_Control(pDX, IDC_CLIP, m_clip_ctrl);
DDX_Control(pDX, IDC_CUBIC, m_cubic_ctrl);
DDX_Control(pDX, IDC_SCROLL_CUBIC, m_scroll_cubic_ctrl);
DDX_Control(pDX, IDC_LINES, m_line_ctrl);
DDX_Control(pDX, IDC_SCROLL_3D_TRANS, m_scroll_3d_trans_ctrl);
DDX_Control(pDX, IDC_3D_TRANS, m_3d_trans_ctrl);
DDX_Control(pDX, IDC_POLY, m_poly_ctrl);
DDX_Control(pDX, IDC_FOG, m_fog_ctrl);
DDX_Control(pDX, IDC_ZBUFFER, m_z_ctrl);
DDX_Control(pDX, IDC_SCROLL_3D_WIDTH, m_scroll_3d_width_ctrl);
DDX_Control(pDX, IDC_ANTI_ALIAS_3D, m_aa_3d_ctrl);
DDX_Control(pDX, IDC_3D_WIDTH, m_3d_width_ctrl);
DDX_Control(pDX, IDC_ANTI_ALIAS_2D, m_aa_2d_ctrl);
DDX_Control(pDX, IDC_SCROLL_2D_WIDTH, m_scroll_2d_width_ctrl);
DDX_Control(pDX, IDC_2D_WIDTH, m_2d_width_ctrl);
DDX_Control(pDX, IDC_CONFIG_3D, m_3d_ctrl);
DDX_Control(pDX, IDC_CONFIG_2D, m_2d_ctrl);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CConfigDialog, CDialog)
//{{AFX_MSG_MAP(CConfigDialog)
ON_WM_HSCROLL()
ON_BN_CLICKED(IDC_ANTI_ALIAS_2D, OnAntiAlias2d)
ON_BN_CLICKED(IDC_CONFIG_2D, OnConfig2d)
ON_BN_CLICKED(IDC_CONFIG_3D, OnConfig3d)
ON_BN_CLICKED(IDC_COLOR_2D, OnColor2d)
ON_BN_CLICKED(IDC_ANTI_ALIAS_3D, OnAntiAlias3d)
ON_BN_CLICKED(IDC_COLOR_3D, OnColor3d)
ON_BN_CLICKED(IDC_COLOR_FOG, OnColorFog)
ON_BN_CLICKED(IDC_FOG, OnFog)
ON_CBN_SELCHANGE(IDC_ZBUFFER, OnSelchangeZbuffer)
ON_BN_CLICKED(IDC_POLY, OnPoly)
ON_BN_CLICKED(IDC_LINES, OnLines)
ON_BN_CLICKED(IDC_CLIP, OnClip)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CConfigDialog message handlers
void CConfigDialog::Set2DText()
{
char s[40];
sprintf(s, "Line Width = %6.3f", portals.width_2d * 0.5f);
m_2d_width_ctrl.SetWindowText(s);
}
void CConfigDialog::Set3DText()
{
char s[40];
sprintf(s, "Line Width = %6.3f", portals.width_3d * 0.5f);
m_3d_width_ctrl.SetWindowText(s);
}
void CConfigDialog::Set3DTransText()
{
char s[40];
sprintf(s, "Polygon transparency = %d%%", (int)portals.trans_3d);
m_3d_trans_ctrl.SetWindowText(s);
}
void CConfigDialog::SetClipText()
{
char s[40];
sprintf(s, "Cubic clip range = %d", (int)portals.clip_range * 64);
m_cubic_ctrl.SetWindowText(s);
}
bool CConfigDialog::OnInitDialog()
{
CDialog::OnInitDialog();
m_2d_ctrl.SetCheck(portals.show_2d);
m_aa_2d_ctrl.SetCheck(portals.aa_2d);
Set2DText();
m_scroll_2d_width_ctrl.SetScrollRange(2, 40, FALSE);
m_scroll_2d_width_ctrl.SetScrollPos((int)portals.width_2d, TRUE);
m_3d_ctrl.SetCheck(portals.show_3d);
m_fog_ctrl.SetCheck(portals.fog);
m_poly_ctrl.SetCheck(portals.polygons);
m_line_ctrl.SetCheck(portals.lines);
m_aa_3d_ctrl.SetCheck(portals.aa_3d);
m_z_ctrl.SetCurSel(portals.zbuffer);
m_clip_ctrl.SetCheck(portals.clip);
Set3DText();
Set3DTransText();
SetClipText();
m_scroll_3d_width_ctrl.SetScrollRange(2, 40, FALSE);
m_scroll_3d_width_ctrl.SetScrollPos((int)portals.width_3d, TRUE);
m_scroll_3d_trans_ctrl.SetScrollRange(0, 100, FALSE);
m_scroll_3d_trans_ctrl.SetScrollPos((int)portals.trans_3d, TRUE);
m_scroll_cubic_ctrl.SetScrollRange(1, 128, FALSE);
m_scroll_cubic_ctrl.SetScrollPos((int)portals.clip_range, TRUE);
return true; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CConfigDialog::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
float *adj;
float scr_min, scr_max, scr_big;
if(nSBCode == SB_THUMBPOSITION)
{
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
return;
}
if(pScrollBar == &m_scroll_2d_width_ctrl)
{
scr_min = 2.0f;
scr_max = 40.0f;
scr_big = 4.0f;
adj = &portals.width_2d;
}
else if(pScrollBar == &m_scroll_3d_width_ctrl)
{
scr_min = 2.0f;
scr_max = 40.0f;
scr_big = 4.0f;
adj = &portals.width_3d;
}
else if(pScrollBar == &m_scroll_3d_trans_ctrl)
{
scr_min = 0.0f;
scr_max = 100.0f;
scr_big = 10.0f;
adj = &portals.trans_3d;
}
else if(pScrollBar == &m_scroll_cubic_ctrl)
{
scr_min = 1.0f;
scr_max = 128.0f;
scr_big = 8.0f;
adj = &portals.clip_range;
}
else
{
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
return;
}
switch(nSBCode)
{
case SB_LEFT:
*adj = scr_min;
pScrollBar->SetScrollPos((int)scr_min, TRUE);
break;
case SB_RIGHT:
*adj = scr_max;
pScrollBar->SetScrollPos((int)scr_max, TRUE);
break;
case SB_LINELEFT:
*adj -= 1.0f;
if(*adj < scr_min)
*adj = scr_min;
pScrollBar->SetScrollPos((int)(*adj), TRUE);
break;
case SB_LINERIGHT:
*adj += 1.0f;
if(*adj > scr_max)
*adj = scr_max;
pScrollBar->SetScrollPos((int)(*adj), TRUE);
break;
case SB_PAGELEFT:
*adj -= scr_big;
if(*adj < scr_min)
*adj = scr_min;
pScrollBar->SetScrollPos((int)(*adj), TRUE);
break;
case SB_PAGERIGHT:
*adj += scr_big;
if(*adj > scr_max)
*adj = scr_max;
pScrollBar->SetScrollPos((int)(*adj), TRUE);
break;
case SB_THUMBTRACK:
*adj = (float)nPos;
break;
case SB_ENDSCROLL:
pScrollBar->SetScrollPos((int)(*adj), TRUE);
break;
default:
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
if(pScrollBar == &m_scroll_2d_width_ctrl)
{
Set2DText();
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_2D);
}
else if(pScrollBar == &m_scroll_3d_width_ctrl)
{
Set3DText();
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
else if(pScrollBar == &m_scroll_3d_trans_ctrl)
{
Set3DTransText();
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
else if(pScrollBar == &m_scroll_cubic_ctrl)
{
SetClipText();
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
}
void CConfigDialog::OnAntiAlias2d()
{
portals.aa_2d = m_aa_2d_ctrl.GetCheck();
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_2D);
}
void CConfigDialog::OnConfig2d()
{
portals.show_2d = m_2d_ctrl.GetCheck();
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_2D);
}
void CConfigDialog::OnColor2d()
{
CColorDialog dlg(portals.color_2d, CC_ANYCOLOR, this);
if(dlg.DoModal() == IDOK)
{
portals.color_2d = dlg.GetColor();
portals.FixColors();
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_2D);
}
}
void CConfigDialog::OnConfig3d()
{
portals.show_3d = m_3d_ctrl.GetCheck();
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
void CConfigDialog::OnAntiAlias3d()
{
portals.aa_3d = m_aa_3d_ctrl.GetCheck();
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
void CConfigDialog::OnColor3d()
{
CColorDialog dlg(portals.color_3d, CC_ANYCOLOR, this);
if(dlg.DoModal() == IDOK)
{
portals.color_3d = dlg.GetColor();
portals.FixColors();
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
}
void CConfigDialog::OnColorFog()
{
CColorDialog dlg(portals.color_fog, CC_ANYCOLOR, this);
if(dlg.DoModal() == IDOK)
{
portals.color_fog = dlg.GetColor();
portals.FixColors();
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
}
void CConfigDialog::OnFog()
{
portals.fog = m_fog_ctrl.GetCheck();
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
void CConfigDialog::OnSelchangeZbuffer()
{
portals.zbuffer = m_z_ctrl.GetCurSel();
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
void CConfigDialog::OnPoly()
{
portals.polygons = m_poly_ctrl.GetCheck();
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
void CConfigDialog::OnLines()
{
portals.lines = m_line_ctrl.GetCheck();
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
void CConfigDialog::OnClip()
{
portals.clip = m_clip_ctrl.GetCheck();
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
#endif // GTK_PLUGIN

View File

@@ -0,0 +1,107 @@
/*
PrtView plugin for GtkRadiant
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#if !defined(AFX_CONFIGDIALOG_H__E484E672_2088_11D4_BFFA_204C4F4F5020__INCLUDED_)
#define AFX_CONFIGDIALOG_H__E484E672_2088_11D4_BFFA_204C4F4F5020__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// ConfigDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CConfigDialog dialog
#ifdef GTK_PLUGIN
void DoConfigDialog ();
#else
class CConfigDialog : public CDialog
{
// Construction
public:
CConfigDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CConfigDialog)
enum { IDD = IDD_CONFIG };
CButton m_clip_ctrl;
CStatic m_cubic_ctrl;
CScrollBar m_scroll_cubic_ctrl;
CButton m_line_ctrl;
CScrollBar m_scroll_3d_trans_ctrl;
CStatic m_3d_trans_ctrl;
CButton m_poly_ctrl;
CButton m_fog_ctrl;
CComboBox m_z_ctrl;
CScrollBar m_scroll_3d_width_ctrl;
CButton m_aa_3d_ctrl;
CStatic m_3d_width_ctrl;
CButton m_aa_2d_ctrl;
CScrollBar m_scroll_2d_width_ctrl;
CStatic m_2d_width_ctrl;
CButton m_3d_ctrl;
CButton m_2d_ctrl;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CConfigDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
void Set2DText();
void Set3DText();
void Set3DTransText();
void SetClipText();
// Generated message map functions
//{{AFX_MSG(CConfigDialog)
virtual qboolean OnInitDialog();
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnAntiAlias2d();
afx_msg void OnConfig2d();
afx_msg void OnConfig3d();
afx_msg void OnColor2d();
afx_msg void OnAntiAlias3d();
afx_msg void OnColor3d();
afx_msg void OnColorFog();
afx_msg void OnFog();
afx_msg void OnSelchangeZbuffer();
afx_msg void OnPoly();
afx_msg void OnLines();
afx_msg void OnClip();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#endif // GTK_PLUGIN
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CONFIGDIALOG_H__E484E672_2088_11D4_BFFA_204C4F4F5020__INCLUDED_)

View File

@@ -0,0 +1,286 @@
/*
PrtView plugin for GtkRadiant
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// LoadPortalFileDialog.cpp : implementation file
//
#include "stdafx.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
//static char THIS_FILE[] = __FILE__;
#endif
#ifdef GTK_PLUGIN
static void dialog_button_callback (GtkWidget *widget, gpointer data)
{
GtkWidget *parent;
int *loop, *ret;
parent = gtk_widget_get_toplevel (widget);
loop = (int*)g_object_get_data (G_OBJECT (parent), "loop");
ret = (int*)g_object_get_data (G_OBJECT (parent), "ret");
*loop = 0;
*ret = (int)data;
}
static gint dialog_delete_callback (GtkWidget *widget, GdkEvent* event, gpointer data)
{
int *loop;
gtk_widget_hide (widget);
loop = (int*)g_object_get_data (G_OBJECT (widget), "loop");
*loop = 0;
return TRUE;
}
static void file_sel_callback (GtkWidget *widget, gpointer data)
{
GtkWidget *parent;
int *loop;
char **filename;
parent = gtk_widget_get_toplevel (widget);
loop = (int*)g_object_get_data (G_OBJECT (parent), "loop");
filename = (char**)g_object_get_data (G_OBJECT (parent), "filename");
*loop = 0;
if ((int)data == IDOK)
*filename = g_strdup (gtk_file_selection_get_filename (GTK_FILE_SELECTION (parent)));
}
static void change_clicked (GtkWidget *widget, gpointer data)
{
GtkWidget* file_sel;
char* filename = NULL;
int loop = 1;
file_sel = gtk_file_selection_new ("Locate portal (.prt) file");
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_sel)->ok_button), "clicked",
GTK_SIGNAL_FUNC (file_sel_callback), GINT_TO_POINTER (IDOK));
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_sel)->cancel_button), "clicked",
GTK_SIGNAL_FUNC (file_sel_callback), GINT_TO_POINTER (IDCANCEL));
gtk_signal_connect (GTK_OBJECT (file_sel), "delete_event",
GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
gtk_file_selection_hide_fileop_buttons (GTK_FILE_SELECTION (file_sel));
g_object_set_data (G_OBJECT (file_sel), "loop", &loop);
g_object_set_data (G_OBJECT (file_sel), "filename", &filename);
gtk_file_selection_set_filename (GTK_FILE_SELECTION (file_sel), portals.fn);
gtk_grab_add (file_sel);
gtk_widget_show (file_sel);
while (loop)
gtk_main_iteration ();
gtk_grab_remove (file_sel);
gtk_widget_destroy (file_sel);
if (filename != NULL)
{
strcpy (portals.fn, filename);
gtk_entry_set_text (GTK_ENTRY (data), filename);
g_free (filename);
}
}
int DoLoadPortalFileDialog ()
{
GtkWidget *dlg, *vbox, *hbox, *button, *entry, *check2d, *check3d;
int loop = 1, ret = IDCANCEL;
dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (dlg), "Load .prt");
gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
g_object_set_data (G_OBJECT (dlg), "loop", &loop);
g_object_set_data (G_OBJECT (dlg), "ret", &ret);
vbox = gtk_vbox_new (FALSE, 5);
gtk_widget_show (vbox);
gtk_container_add (GTK_CONTAINER (dlg), vbox);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
entry = gtk_entry_new ();
gtk_widget_show (entry);
gtk_entry_set_editable (GTK_ENTRY (entry), FALSE);
gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);
hbox = gtk_hbox_new (FALSE, 5);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
check3d = gtk_check_button_new_with_label ("Show 3D");
gtk_widget_show (check3d);
gtk_box_pack_start (GTK_BOX (hbox), check3d, FALSE, FALSE, 0);
check2d = gtk_check_button_new_with_label ("Show 2D");
gtk_widget_show (check2d);
gtk_box_pack_start (GTK_BOX (hbox), check2d, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Change");
gtk_widget_show (button);
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (change_clicked), entry);
gtk_widget_set_usize (button, 60, -2);
hbox = gtk_hbox_new (FALSE, 5);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Cancel");
gtk_widget_show (button);
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
gtk_widget_set_usize (button, 60, -2);
button = gtk_button_new_with_label ("OK");
gtk_widget_show (button);
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
gtk_widget_set_usize (button, 60, -2);
strcpy (portals.fn, g_FuncTable.m_pfnGetMapName());
char* fn = strrchr (portals.fn, '.');
if (fn != NULL)
{
strcpy(fn, ".prt");
}
gtk_entry_set_text (GTK_ENTRY (entry), portals.fn);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check2d), portals.show_2d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check3d), portals.show_3d);
gtk_grab_add (dlg);
gtk_widget_show (dlg);
while (loop)
gtk_main_iteration ();
if (ret == IDOK)
{
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;
}
gtk_grab_remove (dlg);
gtk_widget_destroy (dlg);
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

View File

@@ -0,0 +1,77 @@
/*
PrtView plugin for GtkRadiant
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#if !defined(AFX_LOADPORTALFILEDIALOG_H__6BEDE392_1FDC_11D4_BFF7_204C4F4F5020__INCLUDED_)
#define AFX_LOADPORTALFILEDIALOG_H__6BEDE392_1FDC_11D4_BFF7_204C4F4F5020__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// LoadPortalFileDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CLoadPortalFileDialog dialog
#ifdef GTK_PLUGIN
int DoLoadPortalFileDialog ();
#else
class CLoadPortalFileDialog : public CDialog
{
// Construction
public:
CLoadPortalFileDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CLoadPortalFileDialog)
enum { IDD = IDD_LOAD };
CButton m_3d_ctrl;
CButton m_2d_ctrl;
CStatic m_fn_ctrl;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CLoadPortalFileDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CLoadPortalFileDialog)
virtual qboolean OnInitDialog();
virtual void OnOK();
afx_msg void OnLoadOther();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#endif // GTK_PLUGIN
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_LOADPORTALFILEDIALOG_H__6BEDE392_1FDC_11D4_BFF7_204C4F4F5020__INCLUDED_)

BIN
contrib/prtview/PrtView.aps Normal file

Binary file not shown.

View File

@@ -0,0 +1,8 @@
; PrtView.def : Declares the module parameters for the DLL.
LIBRARY "PrtView"
; DESCRIPTION 'PrtView Windows Dynamic Link Library'
EXPORTS
; Explicit exports can go here
Synapse_EnumerateInterfaces @1

195
contrib/prtview/PrtView.dsp Normal file
View File

@@ -0,0 +1,195 @@
# Microsoft Developer Studio Project File - Name="PrtView" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=PrtView - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "PrtView.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "PrtView.mak" CFG="PrtView - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "PrtView - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "PrtView - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName "PrtView"
# PROP Scc_LocalPath "."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "PrtView - Win32 Release"
# PROP BASE Use_MFC 6
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 6
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
F90=df.exe
# ADD BASE F90 /include:"Release/"
# ADD F90 /include:"Release/"
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\STLport\stlport" /I "..\..\..\libxml2\include" /I "..\..\libs" /I "..\..\include" /I "..\..\..\gtk2-win32\include\glib-2.0" /I "..\..\..\gtk2-win32\lib\glib-2.0\include" /I "..\..\..\gtk2-win32\lib\gtk-2.0\include" /I "..\..\..\gtk2-win32\include\gtk-2.0" /I "..\..\..\gtk2-win32\include\gtk-2.0\gdk" /I "..\..\..\gtk2-win32\include\pango-1.0" /I "..\..\..\gtk2-win32\include\atk-1.0" /D "NDEBUG" /D "GTK_PLUGIN" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_USRDLL" /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL"
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL"
# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 glib-2.0.lib gobject-2.0.lib gdk-win32-2.0.lib gtk-win32-2.0.lib pango-1.0.lib /nologo /subsystem:windows /dll /machine:I386 /def:".\PrtView.def" /libpath:"..\..\..\gtk2-win32\lib"
# SUBTRACT LINK32 /pdb:none
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Desc=Copy to dir...
PostBuild_Cmds=copy Release\PrtView.dll "..\..\install\plugins"
# End Special Build Tool
!ELSEIF "$(CFG)" == "PrtView - Win32 Debug"
# PROP BASE Use_MFC 6
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 6
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
F90=df.exe
# ADD BASE F90 /include:"Debug/"
# ADD F90 /browser /include:"Debug/"
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /MDd /W3 /ZI /Od /I "..\..\..\STLport\stlport" /I "..\..\..\libxml2\include" /I "..\..\libs" /I "..\..\include" /I "..\..\..\gtk2-win32\include\glib-2.0" /I "..\..\..\gtk2-win32\lib\glib-2.0\include" /I "..\..\..\gtk2-win32\lib\gtk-2.0\include" /I "..\..\..\gtk2-win32\include\gtk-2.0" /I "..\..\..\gtk2-win32\include\gtk-2.0\gdk" /I "..\..\..\gtk2-win32\include\pango-1.0" /I "..\..\..\gtk2-win32\include\atk-1.0" /D "_DEBUG" /D "GTK_PLUGIN" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_USRDLL" /FR /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL"
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL"
# ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 glib-2.0.lib gobject-2.0.lib gdk-win32-2.0.lib gtk-win32-2.0.lib pango-1.0.lib /nologo /subsystem:windows /dll /debug /machine:I386 /def:".\PrtView.def" /pdbtype:sept /libpath:"..\..\..\gtk2-win32\lib"
# SUBTRACT LINK32 /pdb:none
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Desc=Copy to dir...
PostBuild_Cmds=copy Debug\PrtView.dll "..\..\install\plugins"
# End Special Build Tool
!ENDIF
# Begin Target
# Name "PrtView - Win32 Release"
# Name "PrtView - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\AboutDialog.cpp
# End Source File
# Begin Source File
SOURCE=.\ConfigDialog.cpp
# End Source File
# Begin Source File
SOURCE=.\LoadPortalFileDialog.cpp
# End Source File
# Begin Source File
SOURCE=.\Portals.cpp
# End Source File
# Begin Source File
SOURCE=.\PrtView.cpp
# End Source File
# Begin Source File
SOURCE=.\PrtView.def
# PROP Exclude_From_Build 1
# End Source File
# Begin Source File
SOURCE=.\PrtView.rc
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# ADD CPP /Yc"stdafx.h"
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\AboutDialog.h
# End Source File
# Begin Source File
SOURCE=.\ConfigDialog.h
# End Source File
# Begin Source File
SOURCE=.\LoadPortalFileDialog.h
# End Source File
# Begin Source File
SOURCE=.\Portals.h
# End Source File
# Begin Source File
SOURCE=.\PrtView.h
# End Source File
# Begin Source File
SOURCE=.\PrtView2.h
# End Source File
# Begin Source File
SOURCE=.\Resource.h
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\res\PrtView.rc2
# End Source File
# End Group
# Begin Source File
SOURCE=.\ReadMe.txt
# End Source File
# End Target
# End Project

264
contrib/prtview/PrtView.rc Normal file
View File

@@ -0,0 +1,264 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
"#ifdef _WIN32\r\n"
"LANGUAGE 9, 1\r\n"
"#pragma code_page(1252)\r\n"
"#endif\r\n"
"#include ""res\\PrtView.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
"#include ""afxres.rc"" // Standard components\r\n"
"#endif\0"
END
#endif // APSTUDIO_INVOKED
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 0,0,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "\0"
VALUE "CompanyName", "\0"
VALUE "FileDescription", "Q3Radiant Portal Viewer\0"
VALUE "FileVersion", "1.000\0"
VALUE "InternalName", "PrtView\0"
VALUE "LegalCopyright", "GNU Copyleft (C) 2000\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "PrtView.DLL\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "Q3Radiant Portal Viewer\0"
VALUE "ProductVersion", "1.000\0"
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // !_MAC
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUT DIALOG DISCARDABLE 0, 0, 186, 52
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About Portal Viewer"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,129,16,50,14
LTEXT "Version 1.000\r\rWritten by Geoffrey DeWan\rgdewan@prairienet.org",
IDC_STATIC,7,7,116,38
END
IDD_LOAD DIALOGEX 0, 0, 224, 69
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Load .prt"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,167,48,50,14
PUSHBUTTON "Change",IDC_LOAD_OTHER,167,22,50,14
CONTROL "Show 3D",IDC_LOAD_3D,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,7,23,52,13
CONTROL "Show 2D",IDC_LOAD_2D,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,67,23,61,13
PUSHBUTTON "Cancel",IDCANCEL,113,48,50,14
LTEXT "",IDC_LOAD_FILE_NAME,7,7,209,12,SS_CENTERIMAGE,
WS_EX_CLIENTEDGE
END
IDD_CONFIG DIALOG DISCARDABLE 0, 0, 262, 260
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Portal Viewer Configuration"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,205,239,50,14
GROUPBOX "3D View",IDC_STATIC,7,7,248,149
SCROLLBAR IDC_SCROLL_3D_WIDTH,15,20,144,10
LTEXT "-",IDC_3D_WIDTH,167,20,82,10,SS_CENTERIMAGE
PUSHBUTTON "Color",IDC_COLOR_3D,15,41,50,14
CONTROL "Anti-Alias (May not work on some video cards)",
IDC_ANTI_ALIAS_3D,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
81,38,174,17
PUSHBUTTON "Depth Color",IDC_COLOR_FOG,15,60,50,14
CONTROL "Depth Cue",IDC_FOG,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,81,61,57,13
CONTROL "Lines",IDC_LINES,"Button",BS_AUTO3STATE | WS_TABSTOP,
140,61,49,13
CONTROL "Polygons",IDC_POLY,"Button",BS_AUTO3STATE | WS_TABSTOP,
206,61,49,13
COMBOBOX IDC_ZBUFFER,15,85,231,109,CBS_DROPDOWNLIST | WS_TABSTOP
SCROLLBAR IDC_SCROLL_3D_TRANS,15,105,128,10
LTEXT "-",IDC_3D_TRANS,152,105,95,10,SS_CENTERIMAGE
CONTROL "Show",IDC_CONFIG_3D,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,15,137,52,13
GROUPBOX "2D View",IDC_STATIC,7,158,248,72
SCROLLBAR IDC_SCROLL_2D_WIDTH,15,172,144,10
LTEXT "-",IDC_2D_WIDTH,166,172,82,10,SS_CENTERIMAGE
PUSHBUTTON "Color",IDC_COLOR_2D,15,190,50,14
CONTROL "Anti-Alias (May not work on some video cards)",
IDC_ANTI_ALIAS_2D,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
81,193,174,13
CONTROL "Show",IDC_CONFIG_2D,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,15,212,61,13
SCROLLBAR IDC_SCROLL_CUBIC,15,122,128,10
LTEXT "-",IDC_CUBIC,152,122,95,10,SS_CENTERIMAGE
CONTROL "Portal cubic clipper",IDC_CLIP,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,147,137,52,13
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_ABOUT, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 45
END
IDD_LOAD, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 217
TOPMARGIN, 7
BOTTOMMARGIN, 62
END
IDD_CONFIG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 255
VERTGUIDE, 15
TOPMARGIN, 7
BOTTOMMARGIN, 253
HORZGUIDE, 21
HORZGUIDE, 31
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog Info
//
IDD_CONFIG DLGINIT
BEGIN
IDC_ZBUFFER, 0x403, 62, 0
0x2d5a, 0x7542, 0x6666, 0x7265, 0x5420, 0x7365, 0x2074, 0x6e61, 0x2064,
0x7257, 0x7469, 0x2065, 0x7228, 0x6365, 0x6d6f, 0x656d, 0x646e, 0x6620,
0x726f, 0x7320, 0x6c6f, 0x6469, 0x2020, 0x726f, 0x6e20, 0x206f, 0x6f70,
0x796c, 0x6f67, 0x736e, 0x0029,
IDC_ZBUFFER, 0x403, 56, 0
0x2d5a, 0x7542, 0x6666, 0x7265, 0x5420, 0x7365, 0x2074, 0x6e4f, 0x796c,
0x2820, 0x6572, 0x6f63, 0x6d6d, 0x6e65, 0x2064, 0x6f66, 0x2072, 0x7274,
0x6e61, 0x7073, 0x7261, 0x6e65, 0x2074, 0x6f70, 0x796c, 0x6f67, 0x736e,
0x0029,
IDC_ZBUFFER, 0x403, 13, 0
0x2d5a, 0x7542, 0x6666, 0x7265, 0x4f20, 0x6666, "\000"
0
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE 9, 1
#pragma code_page(1252)
#endif
#include "res\PrtView.rc2" // non-Microsoft Visual C++ edited resources
#include "afxres.rc" // Standard components
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,12 @@
Put PrtView.dll in the Q3Radiant plugins directory.
This program is pretty self explanitary, but point needs to
be mentioned. In the configuration menu for 3D view options,
the lines and polygons flags are tri-state. In the third state,
the lines or polygons will only be drawn if the have the
hint flag set. Older version of q3map will not set this flag
and the hint shader may have to be modified to set it. As of
this writing, I do not know all the details.
Geoffrey DeWan
gdewan@prairienet.org

View File

@@ -0,0 +1,216 @@
<?xml version="1.0" encoding = "Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.00"
Name="PrtView"
Keyword="MFCProj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="2"
UseOfMFC="2"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\STLport\stlport,..\..\..\libxml2\include,..\..\libs,..\..\include,..\..\..\gtk2-win32\include\glib-2.0,..\..\..\gtk2-win32\lib\glib-2.0\include,..\..\..\gtk2-win32\lib\gtk-2.0\include,..\..\..\gtk2-win32\include\gtk-2.0,..\..\..\gtk2-win32\include\gtk-2.0\gdk,..\..\..\gtk2-win32\include\pango-1.0,..\..\..\gtk2-win32\include\atk-1.0"
PreprocessorDefinitions="_DEBUG;GTK_PLUGIN;WIN32;_WINDOWS;_USRDLL"
RuntimeLibrary="3"
UsePrecompiledHeader="3"
PrecompiledHeaderThrough="stdafx.h"
PrecompiledHeaderFile=".\Debug/PrtView.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="glib-2.0.lib gobject-2.0.lib gdk-win32-2.0.lib gtk-win32-2.0.lib pango-1.0.lib"
OutputFile=".\Debug/PrtView.dll"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\..\..\gtk2-win32\lib"
ModuleDefinitionFile=".\PrtView.def"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\Debug/PrtView.pdb"
SubSystem="2"
ImportLibrary=".\Debug/PrtView.lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Debug/PrtView.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_AFXDLL;_DEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="2"
UseOfMFC="2"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\..\STLport\stlport,..\..\..\libxml2\include,..\..\libs,..\..\include,..\..\..\gtk2-win32\include\glib-2.0,..\..\..\gtk2-win32\lib\glib-2.0\include,..\..\..\gtk2-win32\lib\gtk-2.0\include,..\..\..\gtk2-win32\include\gtk-2.0,..\..\..\gtk2-win32\include\gtk-2.0\gdk,..\..\..\gtk2-win32\include\pango-1.0,..\..\..\gtk2-win32\include\atk-1.0"
PreprocessorDefinitions="NDEBUG;GTK_PLUGIN;WIN32;_WINDOWS;_USRDLL"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="3"
PrecompiledHeaderThrough="stdafx.h"
PrecompiledHeaderFile=".\Release/PrtView.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="glib-2.0.lib gobject-2.0.lib gdk-win32-2.0.lib gtk-win32-2.0.lib pango-1.0.lib"
OutputFile=".\Release/PrtView.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\..\..\gtk2-win32\lib"
ModuleDefinitionFile=".\PrtView.def"
ProgramDatabaseFile=".\Release/PrtView.pdb"
SubSystem="2"
ImportLibrary=".\Release/PrtView.lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Release/PrtView.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_AFXDLL;NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
</Configurations>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath=".\AboutDialog.cpp">
</File>
<File
RelativePath=".\ConfigDialog.cpp">
</File>
<File
RelativePath=".\LoadPortalFileDialog.cpp">
</File>
<File
RelativePath=".\Portals.cpp">
</File>
<File
RelativePath=".\PrtView.cpp">
</File>
<File
RelativePath=".\PrtView.def">
</File>
<File
RelativePath=".\PrtView.rc">
</File>
<File
RelativePath=".\StdAfx.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath=".\AboutDialog.h">
</File>
<File
RelativePath=".\ConfigDialog.h">
</File>
<File
RelativePath=".\LoadPortalFileDialog.h">
</File>
<File
RelativePath=".\Portals.h">
</File>
<File
RelativePath=".\PrtView.h">
</File>
<File
RelativePath=".\PrtView2.h">
</File>
<File
RelativePath=".\Resource.h">
</File>
<File
RelativePath=".\StdAfx.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe">
<File
RelativePath=".\res\PrtView.rc2">
</File>
</Filter>
<File
RelativePath=".\ReadMe.txt">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

732
contrib/prtview/gtkdlgs.cpp Normal file
View File

@@ -0,0 +1,732 @@
/*
PrtView plugin for GtkRadiant
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//
// PrtView dialogs done with GTK+
//
#include <stdio.h>
#include "stdafx.h"
// =============================================================================
// Static functions
static void dialog_button_callback (GtkWidget *widget, gpointer data)
{
GtkWidget *parent;
int *loop, *ret;
parent = gtk_widget_get_toplevel (widget);
loop = (int*)g_object_get_data (G_OBJECT (parent), "loop");
ret = (int*)g_object_get_data (G_OBJECT (parent), "ret");
*loop = 0;
*ret = (int)data;
}
static gint dialog_delete_callback (GtkWidget *widget, GdkEvent* event, gpointer data)
{
int *loop;
gtk_widget_hide (widget);
loop = (int*)g_object_get_data (G_OBJECT (widget), "loop");
*loop = 0;
return TRUE;
}
static void file_sel_callback (GtkWidget *widget, gpointer data)
{
GtkWidget *parent;
int *loop;
char **filename;
parent = gtk_widget_get_toplevel (widget);
loop = (int*)g_object_get_data (G_OBJECT (parent), "loop");
filename = (char**)g_object_get_data (G_OBJECT (parent), "filename");
*loop = 0;
if ((int)data == IDOK)
*filename = g_strdup (gtk_file_selection_get_filename (GTK_FILE_SELECTION (parent)));
}
static void change_clicked (GtkWidget *widget, gpointer data)
{
GtkWidget* file_sel;
char* filename = NULL;
int loop = 1;
file_sel = gtk_file_selection_new ("Locate portal (.prt) file");
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_sel)->ok_button), "clicked",
GTK_SIGNAL_FUNC (file_sel_callback), GINT_TO_POINTER (IDOK));
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_sel)->cancel_button), "clicked",
GTK_SIGNAL_FUNC (file_sel_callback), GINT_TO_POINTER (IDCANCEL));
gtk_signal_connect (GTK_OBJECT (file_sel), "delete_event",
GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
gtk_file_selection_hide_fileop_buttons (GTK_FILE_SELECTION (file_sel));
g_object_set_data (G_OBJECT (file_sel), "loop", &loop);
g_object_set_data (G_OBJECT (file_sel), "filename", &filename);
gtk_file_selection_set_filename (GTK_FILE_SELECTION (file_sel), portals.fn);
gtk_grab_add (file_sel);
gtk_widget_show (file_sel);
while (loop)
gtk_main_iteration ();
gtk_grab_remove (file_sel);
gtk_widget_destroy (file_sel);
if (filename != NULL)
{
strcpy (portals.fn, filename);
gtk_entry_set_text (GTK_ENTRY (data), filename);
g_free (filename);
}
}
// =============================================================================
// LoadPortalFile dialog
int DoLoadPortalFileDialog ()
{
GtkWidget *dlg, *vbox, *hbox, *button, *entry, *check2d, *check3d;
int loop = 1, ret = IDCANCEL;
dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (dlg), "Load .prt");
gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
g_object_set_data (G_OBJECT (dlg), "loop", &loop);
g_object_set_data (G_OBJECT (dlg), "ret", &ret);
vbox = gtk_vbox_new (FALSE, 5);
gtk_widget_show (vbox);
gtk_container_add (GTK_CONTAINER (dlg), vbox);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
entry = gtk_entry_new ();
gtk_widget_show (entry);
gtk_entry_set_editable (GTK_ENTRY (entry), FALSE);
gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);
hbox = gtk_hbox_new (FALSE, 5);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
check3d = gtk_check_button_new_with_label ("Show 3D");
gtk_widget_show (check3d);
gtk_box_pack_start (GTK_BOX (hbox), check3d, FALSE, FALSE, 0);
check2d = gtk_check_button_new_with_label ("Show 2D");
gtk_widget_show (check2d);
gtk_box_pack_start (GTK_BOX (hbox), check2d, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Change");
gtk_widget_show (button);
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (change_clicked), entry);
gtk_widget_set_usize (button, 60, -2);
hbox = gtk_hbox_new (FALSE, 5);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Cancel");
gtk_widget_show (button);
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
gtk_widget_set_usize (button, 60, -2);
button = gtk_button_new_with_label ("OK");
gtk_widget_show (button);
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
gtk_widget_set_usize (button, 60, -2);
char *fn = g_IBSPTable.m_pfnGetMapName();
strcpy (portals.fn, fn);
fn = strrchr (portals.fn, '.');
if (fn != NULL)
{
*fn = '\0';
strcat (portals.fn, ".prt");
}
gtk_entry_set_text (GTK_ENTRY (entry), portals.fn);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check2d), portals.show_2d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check3d), portals.show_3d);
gtk_grab_add (dlg);
gtk_widget_show (dlg);
while (loop)
gtk_main_iteration ();
if (ret == IDOK)
{
portals.Purge();
portals.show_3d = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check3d));
portals.show_2d = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check2d));
}
gtk_grab_remove (dlg);
gtk_widget_destroy (dlg);
return ret;
}
// =============================================================================
// About dialog
void DoAboutDlg ()
{
GtkWidget *dlg, *hbox, *vbox, *button, *label;
int loop = 1, ret = IDCANCEL;
dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (dlg), "About Portal Viewer");
gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
g_object_set_data (G_OBJECT (dlg), "loop", &loop);
g_object_set_data (G_OBJECT (dlg), "ret", &ret);
hbox = gtk_hbox_new (FALSE, 10);
gtk_widget_show (hbox);
gtk_container_add (GTK_CONTAINER (dlg), hbox);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 10);
label = gtk_label_new ("Version 1.000\n\n"
"Gtk port by Leonardo Zide\nleo@lokigames.com\n\n"
"Written by Geoffrey DeWan\ngdewan@prairienet.org");
gtk_widget_show (label);
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
vbox = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox);
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("OK");
gtk_widget_show (button);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
gtk_widget_set_usize (button, 60, -2);
gtk_grab_add (dlg);
gtk_widget_show (dlg);
while (loop)
gtk_main_iteration ();
gtk_grab_remove (dlg);
gtk_widget_destroy (dlg);
}
// =============================================================================
// Config dialog
static int DoColor (COLORREF *c)
{
GtkWidget* dlg;
double clr[3];
int loop = 1, ret = IDCANCEL;
clr[0] = ((double)GetRValue (*c)) / 255.0;
clr[1] = ((double)GetGValue (*c)) / 255.0;
clr[2] = ((double)GetBValue (*c)) / 255.0;
dlg = gtk_color_selection_dialog_new ("Choose Color");
gtk_color_selection_set_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (dlg)->colorsel), clr);
gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
gtk_signal_connect (GTK_OBJECT (GTK_COLOR_SELECTION_DIALOG (dlg)->ok_button), "clicked",
GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
gtk_signal_connect (GTK_OBJECT (GTK_COLOR_SELECTION_DIALOG (dlg)->cancel_button), "clicked",
GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
g_object_set_data (G_OBJECT (dlg), "loop", &loop);
g_object_set_data (G_OBJECT (dlg), "ret", &ret);
gtk_widget_show(dlg);
gtk_grab_add(dlg);
while (loop)
gtk_main_iteration ();
gtk_color_selection_get_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (dlg)->colorsel), clr);
gtk_grab_remove (dlg);
gtk_widget_destroy (dlg);
if (ret == IDOK)
{
*c = RGB (clr[0]*255, clr[1]*255, clr[2]*255);
}
return ret;
}
static void Set2DText (GtkWidget* label)
{
char s[40];
sprintf(s, "Line Width = %6.3f", portals.width_2d * 0.5f);
gtk_label_set_text (GTK_LABEL (label), s);
}
static void Set3DText (GtkWidget* label)
{
char s[40];
sprintf(s, "Line Width = %6.3f", portals.width_3d * 0.5f);
gtk_label_set_text (GTK_LABEL (label), s);
}
static void Set3DTransText (GtkWidget* label)
{
char s[40];
sprintf(s, "Polygon transparency = %d%%", (int)portals.trans_3d);
gtk_label_set_text (GTK_LABEL (label), s);
}
static void SetClipText (GtkWidget* label)
{
char s[40];
sprintf(s, "Cubic clip range = %d", (int)portals.clip_range * 64);
gtk_label_set_text (GTK_LABEL (label), s);
}
static void OnScroll2d (GtkAdjustment *adj, gpointer data)
{
portals.width_2d = adj->value;
Set2DText (GTK_WIDGET (data));
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_2D);
}
static void OnScroll3d (GtkAdjustment *adj, gpointer data)
{
portals.width_3d = adj->value;
Set3DText (GTK_WIDGET (data));
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
static void OnScrollTrans (GtkAdjustment *adj, gpointer data)
{
portals.trans_3d = adj->value;
Set3DTransText (GTK_WIDGET (data));
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
static void OnScrollClip (GtkAdjustment *adj, gpointer data)
{
portals.clip_range = adj->value;
SetClipText (GTK_WIDGET (data));
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
static void OnAntiAlias2d (GtkWidget *widget, gpointer data)
{
portals.aa_2d = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_2D);
}
static void OnConfig2d (GtkWidget *widget, gpointer data)
{
portals.show_2d = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_2D);
}
static void OnColor2d (GtkWidget *widget, gpointer data)
{
if (DoColor (&portals.color_2d) == IDOK)
{
portals.FixColors();
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_2D);
}
}
static void OnConfig3d (GtkWidget *widget, gpointer data)
{
portals.show_3d = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
static void OnAntiAlias3d (GtkWidget *widget, gpointer data)
{
portals.aa_3d = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
static void OnColor3d (GtkWidget *widget, gpointer data)
{
if (DoColor (&portals.color_3d) == IDOK)
{
portals.FixColors();
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
}
static void OnColorFog (GtkWidget *widget, gpointer data)
{
if (DoColor (&portals.color_fog) == IDOK)
{
portals.FixColors();
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
}
static void OnFog (GtkWidget *widget, gpointer data)
{
portals.fog = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
static void OnSelchangeZbuffer (GtkWidget *widget, gpointer data)
{
portals.zbuffer = GPOINTER_TO_INT (data);
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
static void OnPoly (GtkWidget *widget, gpointer data)
{
portals.polygons = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
static void OnLines (GtkWidget *widget, gpointer data)
{
portals.lines = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
static void OnClip (GtkWidget *widget, gpointer data)
{
portals.clip = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_3D);
}
void DoConfigDialog ()
{
GtkWidget *dlg, *hbox, *vbox, *vbox2, *button, *table, *frame;
GtkWidget *lw3slider, *lw3label, *lw2slider, *lw2label, *zlist, *menu, *item;
GtkWidget *aa2check, *aa3check, *depthcheck, *linescheck, *polyscheck;
GtkWidget *transslider, *translabel, *clipslider, *cliplabel;
GtkWidget *show2check, *show3check, *portalcheck;
int loop = 1, ret = IDCANCEL;
GtkObject *adj;
dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (dlg), "Portal Viewer Configuration");
gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
g_object_set_data (G_OBJECT (dlg), "loop", &loop);
g_object_set_data (G_OBJECT (dlg), "ret", &ret);
vbox = gtk_vbox_new (FALSE, 5);
gtk_widget_show (vbox);
gtk_container_add (GTK_CONTAINER (dlg), vbox);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
frame = gtk_frame_new ("3D View");
gtk_widget_show (frame);
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
vbox2 = gtk_vbox_new (FALSE, 5);
gtk_widget_show (vbox2);
gtk_container_add (GTK_CONTAINER (frame), vbox2);
gtk_container_set_border_width (GTK_CONTAINER (vbox2), 5);
hbox = gtk_hbox_new (FALSE, 5);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (vbox2), hbox, TRUE, TRUE, 0);
adj = gtk_adjustment_new (portals.width_3d, 2, 40, 1, 1, 1);
lw3slider = gtk_hscale_new (GTK_ADJUSTMENT (adj));
gtk_widget_show (lw3slider);
gtk_box_pack_start (GTK_BOX (hbox), lw3slider, TRUE, TRUE, 0);
gtk_scale_set_draw_value (GTK_SCALE (lw3slider), FALSE);
lw3label = gtk_label_new ("");
gtk_widget_show (lw3label);
gtk_box_pack_start (GTK_BOX (hbox), lw3label, FALSE, TRUE, 0);
gtk_signal_connect (adj, "value_changed", GTK_SIGNAL_FUNC (OnScroll3d), lw3label);
table = gtk_table_new (2, 4, FALSE);
gtk_widget_show (table);
gtk_box_pack_start (GTK_BOX (vbox2), table, TRUE, TRUE, 0);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
button = gtk_button_new_with_label ("Color");
gtk_widget_show (button);
gtk_table_attach (GTK_TABLE (table), button, 0, 1, 0, 1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (OnColor3d), NULL);
button = gtk_button_new_with_label ("Depth Color");
gtk_widget_show (button);
gtk_table_attach (GTK_TABLE (table), button, 0, 1, 1, 2,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (OnColorFog), NULL);
aa3check = gtk_check_button_new_with_label ("Anti-Alias (May not work on some video cards)");
gtk_widget_show (aa3check);
gtk_table_attach (GTK_TABLE (table), aa3check, 1, 4, 0, 1,
(GtkAttachOptions) (GTK_EXPAND|GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_signal_connect (GTK_OBJECT (aa3check), "toggled", GTK_SIGNAL_FUNC (OnAntiAlias3d), NULL);
depthcheck = gtk_check_button_new_with_label ("Depth Cue");
gtk_widget_show (depthcheck);
gtk_table_attach (GTK_TABLE (table), depthcheck, 1, 2, 1, 2,
(GtkAttachOptions) (GTK_EXPAND|GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_signal_connect (GTK_OBJECT (depthcheck), "toggled", GTK_SIGNAL_FUNC (OnFog), NULL);
linescheck = gtk_check_button_new_with_label ("Lines");
gtk_widget_show (linescheck);
gtk_table_attach (GTK_TABLE (table), linescheck, 2, 3, 1, 2,
(GtkAttachOptions) (GTK_EXPAND|GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_signal_connect (GTK_OBJECT (linescheck), "toggled", GTK_SIGNAL_FUNC (OnLines), NULL);
polyscheck = gtk_check_button_new_with_label ("Polygons");
gtk_widget_show (polyscheck);
gtk_table_attach (GTK_TABLE (table), polyscheck, 3, 4, 1, 2,
(GtkAttachOptions) (GTK_EXPAND|GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_signal_connect (GTK_OBJECT (polyscheck), "toggled", GTK_SIGNAL_FUNC (OnPoly), NULL);
zlist = gtk_option_menu_new ();
gtk_widget_show (zlist);
gtk_box_pack_start (GTK_BOX (vbox2), zlist, TRUE, FALSE, 0);
menu = gtk_menu_new ();
gtk_widget_show (menu);
gtk_option_menu_set_menu (GTK_OPTION_MENU (zlist), menu);
item = gtk_menu_item_new_with_label ("Z-Buffer Test and Write (recommended for solid or no polygons)");
gtk_widget_show (item);
gtk_signal_connect (GTK_OBJECT (item), "activate",
GTK_SIGNAL_FUNC (OnSelchangeZbuffer), GINT_TO_POINTER (0));
gtk_menu_append (GTK_MENU (menu), item);
item = gtk_menu_item_new_with_label ("Z-Buffer Test Only (recommended for transparent polygons)");
gtk_widget_show (item);
gtk_signal_connect (GTK_OBJECT (item), "activate",
GTK_SIGNAL_FUNC (OnSelchangeZbuffer), GINT_TO_POINTER (1));
gtk_menu_append (GTK_MENU (menu), item);
item = gtk_menu_item_new_with_label ("Z-Buffer Off");
gtk_widget_show (item);
gtk_signal_connect (GTK_OBJECT (item), "activate",
GTK_SIGNAL_FUNC (OnSelchangeZbuffer), GINT_TO_POINTER (2));
gtk_menu_append (GTK_MENU (menu), item);
table = gtk_table_new (2, 2, FALSE);
gtk_widget_show (table);
gtk_box_pack_start (GTK_BOX (vbox2), table, TRUE, TRUE, 0);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
adj = gtk_adjustment_new (portals.trans_3d, 0, 100, 1, 1, 1);
transslider = gtk_hscale_new (GTK_ADJUSTMENT (adj));
gtk_widget_show (transslider);
gtk_table_attach (GTK_TABLE (table), transslider, 0, 1, 0, 1,
(GtkAttachOptions) (GTK_EXPAND|GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_scale_set_draw_value (GTK_SCALE (transslider), FALSE);
translabel = gtk_label_new ("");
gtk_widget_show (translabel);
gtk_table_attach (GTK_TABLE (table), translabel, 1, 2, 0, 1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment (GTK_MISC (translabel), 0.0, 0.0);
gtk_signal_connect (adj, "value_changed", GTK_SIGNAL_FUNC (OnScrollTrans), translabel);
adj = gtk_adjustment_new (portals.clip_range, 1, 128, 1, 1, 1);
clipslider = gtk_hscale_new (GTK_ADJUSTMENT (adj));
gtk_widget_show (clipslider);
gtk_table_attach (GTK_TABLE (table), clipslider, 0, 1, 1, 2,
(GtkAttachOptions) (GTK_EXPAND|GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_scale_set_draw_value (GTK_SCALE (clipslider), FALSE);
cliplabel = gtk_label_new ("");
gtk_widget_show (cliplabel);
gtk_table_attach (GTK_TABLE (table), cliplabel, 1, 2, 1, 2,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment (GTK_MISC (cliplabel), 0.0, 0.0);
gtk_signal_connect (adj, "value_changed", GTK_SIGNAL_FUNC (OnScrollClip), cliplabel);
hbox = gtk_hbox_new (TRUE, 5);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (vbox2), hbox, TRUE, FALSE, 0);
show3check = gtk_check_button_new_with_label ("Show");
gtk_widget_show (show3check);
gtk_box_pack_start (GTK_BOX (hbox), show3check, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (show3check), "toggled", GTK_SIGNAL_FUNC (OnConfig3d), NULL);
portalcheck = gtk_check_button_new_with_label ("Portal cubic clipper");
gtk_widget_show (portalcheck);
gtk_box_pack_start (GTK_BOX (hbox), portalcheck, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (portalcheck), "toggled", GTK_SIGNAL_FUNC (OnClip), NULL);
frame = gtk_frame_new ("2D View");
gtk_widget_show (frame);
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
vbox2 = gtk_vbox_new (FALSE, 5);
gtk_widget_show (vbox2);
gtk_container_add (GTK_CONTAINER (frame), vbox2);
gtk_container_set_border_width (GTK_CONTAINER (vbox2), 5);
hbox = gtk_hbox_new (FALSE, 5);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (vbox2), hbox, TRUE, FALSE, 0);
adj = gtk_adjustment_new (portals.width_2d, 2, 40, 1, 1, 1);
lw2slider = gtk_hscale_new (GTK_ADJUSTMENT (adj));
gtk_widget_show (lw2slider);
gtk_box_pack_start (GTK_BOX (hbox), lw2slider, TRUE, TRUE, 0);
gtk_scale_set_draw_value (GTK_SCALE (lw2slider), FALSE);
lw2label = gtk_label_new ("");
gtk_widget_show (lw2label);
gtk_box_pack_start (GTK_BOX (hbox), lw2label, FALSE, TRUE, 0);
gtk_signal_connect (adj, "value_changed", GTK_SIGNAL_FUNC (OnScroll2d), lw2label);
hbox = gtk_hbox_new (FALSE, 5);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (vbox2), hbox, TRUE, FALSE, 0);
button = gtk_button_new_with_label ("Color");
gtk_widget_show (button);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (OnColor2d), NULL);
gtk_widget_set_usize (button, 60, -2);
aa2check = gtk_check_button_new_with_label ("Anti-Alias (May not work on some video cards)");
gtk_widget_show (aa2check);
gtk_box_pack_start (GTK_BOX (hbox), aa2check, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (aa2check), "toggled", GTK_SIGNAL_FUNC (OnAntiAlias2d), NULL);
hbox = gtk_hbox_new (FALSE, 5);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (vbox2), hbox, TRUE, FALSE, 0);
show2check = gtk_check_button_new_with_label ("Show");
gtk_widget_show (show2check);
gtk_box_pack_start (GTK_BOX (hbox), show2check, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (show2check), "toggled", GTK_SIGNAL_FUNC (OnConfig2d), NULL);
hbox = gtk_hbox_new (FALSE, 5);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("OK");
gtk_widget_show (button);
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
gtk_widget_set_usize (button, 60, -2);
// initialize dialog
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (show2check), portals.show_2d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (aa2check), portals.aa_2d);
Set2DText (lw2label);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (show3check), portals.show_3d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (depthcheck), portals.fog);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (polyscheck), portals.polygons);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (linescheck), portals.lines);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (aa3check), portals.aa_3d);
gtk_option_menu_set_history (GTK_OPTION_MENU (zlist), portals.zbuffer);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (portalcheck), portals.clip);
Set3DText (lw3label);
Set3DTransText (translabel);
SetClipText (cliplabel);
gtk_grab_add (dlg);
gtk_widget_show (dlg);
while (loop)
gtk_main_iteration ();
gtk_grab_remove (dlg);
gtk_widget_destroy (dlg);
}

27
contrib/prtview/gtkdlgs.h Normal file
View File

@@ -0,0 +1,27 @@
/*
PrtView plugin for GtkRadiant
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _GTKDLGS_H_
#define _GTKDLGS_H_
int DoLoadPortalFileDialog ();
void DoAboutDlg ();
void DoConfigDialog ();
#endif // _GTKDLGS_H_

802
contrib/prtview/portals.cpp Normal file
View File

@@ -0,0 +1,802 @@
/*
PrtView plugin for GtkRadiant
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "stdafx.h"
#include <string.h>
#include <stdlib.h>
#ifndef __APPLE__
#include <search.h>
#endif
#include <stdio.h>
#define LINE_BUF 1000
CPortals portals;
CPortalsRender render;
int compare( const void *arg1, const void *arg2 )
{
if(portals.portal[*((int *)arg1)].dist > portals.portal[*((int *)arg2)].dist)
return -1;
else if(portals.portal[*((int *)arg1)].dist < portals.portal[*((int *)arg2)].dist)
return 1;
return 0;
}
CBspPortal::CBspPortal()
{
memset(this, 0, sizeof(CBspPortal));
}
CBspPortal::~CBspPortal()
{
delete[] point;
delete[] inner_point;
}
bool CBspPortal::Build(char *def)
{
char *c = def;
unsigned int n;
int dummy1, dummy2;
int res_cnt, i;
if(portals.hint_flags)
{
res_cnt = sscanf(def, "%u %d %d %d", &point_count, &dummy1, &dummy2, (int *)&hint);
}
else
{
sscanf(def, "%u", &point_count);
hint = qfalse;
}
if(point_count < 3 || (portals.hint_flags && res_cnt < 4))
return qfalse;
point = new CBspPoint[point_count];
inner_point = new CBspPoint[point_count];
for(n = 0; n < point_count; n++)
{
for(; *c != 0 && *c != '('; c++);
if(*c == 0)
return qfalse;
c++;
sscanf(c, "%f %f %f", point[n].p, point[n].p+1, point[n].p+2);
center.p[0] += point[n].p[0];
center.p[1] += point[n].p[1];
center.p[2] += point[n].p[2];
if(n == 0)
{
for(i = 0; i < 3; i++)
{
min[i] = point[n].p[i];
max[i] = point[n].p[i];
}
}
else
{
for(i = 0; i < 3; i++)
{
if(min[i] > point[n].p[i])
min[i] = point[n].p[i];
if(max[i] < point[n].p[i])
max[i] = point[n].p[i];
}
}
}
center.p[0] /= (float)point_count;
center.p[1] /= (float)point_count;
center.p[2] /= (float)point_count;
for(n = 0; n < point_count; n++)
{
inner_point[n].p[0] = (0.01f * center.p[0]) + (0.99f * point[n].p[0]);
inner_point[n].p[1] = (0.01f * center.p[1]) + (0.99f * point[n].p[1]);
inner_point[n].p[2] = (0.01f * center.p[2]) + (0.99f * point[n].p[2]);
}
fp_color_random[0] = (float)(rand() & 0xff) / 255.0f;
fp_color_random[1] = (float)(rand() & 0xff) / 255.0f;
fp_color_random[2] = (float)(rand() & 0xff) / 255.0f;
fp_color_random[3] = 1.0f;
return qtrue;
}
CPortals::CPortals()
{
memset(this, 0, sizeof(CPortals));
}
CPortals::~CPortals()
{
Purge();
}
void CPortals::Purge()
{
delete[] portal;
delete[] portal_sort;
portal = NULL;
portal_sort = NULL;
portal_count = 0;
/*
delete[] node;
node = NULL;
node_count = 0;
*/
}
void CPortals::Load()
{
char buf[LINE_BUF+1];
memset(buf, 0, LINE_BUF + 1);
Purge();
Sys_Printf(MSG_PREFIX "Loading portal file %s.\n", fn);
FILE *in;
in = fopen(fn, "rt");
if(in == NULL)
{
Sys_Printf(" ERROR - could not open file.\n");
return;
}
if(!fgets(buf, LINE_BUF, in))
{
fclose(in);
Sys_Printf(" ERROR - File ended prematurely.\n");
return;
}
if(strncmp("PRT1", buf, 4) != 0)
{
fclose(in);
Sys_Printf(" ERROR - File header indicates wrong file type (should be \"PRT1\").\n");
return;
}
if(!fgets(buf, LINE_BUF, in))
{
fclose(in);
Sys_Printf(" ERROR - File ended prematurely.\n");
return;
}
sscanf(buf, "%u", &node_count);
/*
if(node_count > 0xFFFF)
{
fclose(in);
node_count = 0;
Sys_Printf(" ERROR - Extreme number of nodes, aborting.\n");
return;
}
*/
if(!fgets(buf, LINE_BUF, in))
{
fclose(in);
node_count = 0;
Sys_Printf(" ERROR - File ended prematurely.\n");
return;
}
sscanf(buf, "%u", &portal_count);
if(portal_count > 0xFFFF)
{
fclose(in);
portal_count = 0;
node_count = 0;
Sys_Printf(" ERROR - Extreme number of portals, aborting.\n");
return;
}
if(portal_count < 0)
{
fclose(in);
portal_count = 0;
node_count = 0;
Sys_Printf(" ERROR - number of portals equals 0, aborting.\n");
return;
}
// node = new CBspNode[node_count];
portal = new CBspPortal[portal_count];
portal_sort = new int[portal_count];
unsigned int n;
bool first = qtrue;
unsigned test_vals_1, test_vals_2;
hint_flags = qfalse;
for(n = 0; n < portal_count; )
{
if(!fgets(buf, LINE_BUF, in))
{
fclose(in);
Purge();
Sys_Printf(" ERROR - Could not find information for portal number %d of %d.\n", n + 1, portal_count);
return;
}
if(!portal[n].Build(buf))
{
if(first && sscanf(buf, "%d %d", &test_vals_1, &test_vals_2) == 1) // skip additional counts of later data, not needed
{
// We can count on hint flags being in the file
hint_flags = qtrue;
continue;
}
first = qfalse;
fclose(in);
Purge();
Sys_Printf(" ERROR - Information for portal number %d of %d is not formatted correctly.\n", n + 1, portal_count);
return;
}
n++;
}
fclose(in);
Sys_Printf(" %u portals read in.\n", node_count, portal_count);
}
void CPortals::FixColors()
{
fp_color_2d[0] = (float)GetRValue(color_2d) / 255.0f;
fp_color_2d[1] = (float)GetGValue(color_2d) / 255.0f;
fp_color_2d[2] = (float)GetBValue(color_2d) / 255.0f;
fp_color_2d[3] = 1.0f;
fp_color_3d[0] = (float)GetRValue(color_3d) / 255.0f;
fp_color_3d[1] = (float)GetGValue(color_3d) / 255.0f;
fp_color_3d[2] = (float)GetBValue(color_3d) / 255.0f;
fp_color_3d[3] = 1.0f;
fp_color_fog[0] = 0.0f;//(float)GetRValue(color_fog) / 255.0f;
fp_color_fog[1] = 0.0f;//(float)GetGValue(color_fog) / 255.0f;
fp_color_fog[2] = 0.0f;//(float)GetBValue(color_fog) / 255.0f;
fp_color_fog[3] = 1.0f;
}
CPortalsRender::CPortalsRender()
{
refCount = 1;
}
CPortalsRender::~CPortalsRender()
{
}
void CPortalsRender::Register()
{
g_QglTable.m_pfnHookGL2DWindow( this );
g_QglTable.m_pfnHookGL3DWindow( this );
}
void CPortalsRender::Draw2D( VIEWTYPE vt )
{
if(!portals.show_2d || portals.portal_count < 1)
return;
g_QglTable.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);
if(portals.aa_2d)
{
g_QglTable.m_pfn_qglEnable(GL_BLEND);
g_QglTable.m_pfn_qglEnable(GL_LINE_SMOOTH);
}
else
{
g_QglTable.m_pfn_qglDisable(GL_BLEND);
g_QglTable.m_pfn_qglEnable(GL_LINE_SMOOTH);
}
switch(vt)
{
case XY:
break;
case XZ:
g_QglTable.m_pfn_qglRotatef(270.0f, 1.0f, 0.0f, 0.0f);
break;
case YZ:
g_QglTable.m_pfn_qglRotatef(270.0f, 1.0f, 0.0f, 0.0f);
g_QglTable.m_pfn_qglRotatef(270.0f, 0.0f, 0.0f, 1.0f);
break;
}
g_QglTable.m_pfn_qglLineWidth(portals.width_2d * 0.5f);
g_QglTable.m_pfn_qglColor4fv(portals.fp_color_2d);
unsigned int n, p;
for(n = 0; n < portals.portal_count; n++)
{
g_QglTable.m_pfn_qglBegin(GL_LINE_LOOP);
for(p = 0; p < portals.portal[n].point_count; p++)
g_QglTable.m_pfn_qglVertex3fv(portals.portal[n].point[p].p);
g_QglTable.m_pfn_qglEnd();
}
g_QglTable.m_pfn_qglPopAttrib();
}
/*
* Transform a point (column vector) by a 4x4 matrix. I.e. out = m * in
* Input: m - the 4x4 matrix
* in - the 4x1 vector
* Output: out - the resulting 4x1 vector.
*/
static void transform_point( GLdouble out[4], const GLdouble m[16],
const GLdouble in[4] )
{
#define M(row,col) m[col*4+row]
out[0] = M(0,0) * in[0] + M(0,1) * in[1] + M(0,2) * in[2] + M(0,3) * in[3];
out[1] = M(1,0) * in[0] + M(1,1) * in[1] + M(1,2) * in[2] + M(1,3) * in[3];
out[2] = M(2,0) * in[0] + M(2,1) * in[1] + M(2,2) * in[2] + M(2,3) * in[3];
out[3] = M(3,0) * in[0] + M(3,1) * in[1] + M(3,2) * in[2] + M(3,3) * in[3];
#undef M
}
#include <math.h>
/*
* Perform a 4x4 matrix multiplication (product = a x b).
* Input: a, b - matrices to multiply
* Output: product - product of a and b
*/
static void matmul( GLdouble *product, const GLdouble *a, const GLdouble *b )
{
/* This matmul was contributed by Thomas Malik */
GLdouble temp[16];
GLint i;
#define A(row,col) a[(col<<2)+row]
#define B(row,col) b[(col<<2)+row]
#define T(row,col) temp[(col<<2)+row]
/* i-te Zeile */
for (i = 0; i < 4; i++)
{
T(i, 0) = A(i, 0) * B(0, 0) + A(i, 1) * B(1, 0) + A(i, 2) * B(2, 0) + A(i, 3) * B(3, 0);
T(i, 1) = A(i, 0) * B(0, 1) + A(i, 1) * B(1, 1) + A(i, 2) * B(2, 1) + A(i, 3) * B(3, 1);
T(i, 2) = A(i, 0) * B(0, 2) + A(i, 1) * B(1, 2) + A(i, 2) * B(2, 2) + A(i, 3) * B(3, 2);
T(i, 3) = A(i, 0) * B(0, 3) + A(i, 1) * B(1, 3) + A(i, 2) * B(2, 3) + A(i, 3) * B(3, 3);
}
#undef A
#undef B
#undef T
memcpy ( product, temp, 16*sizeof(GLdouble) );
}
/*
* Compute inverse of 4x4 transformation matrix.
* Code contributed by Jacques Leroy jle@star.be
* Return GL_TRUE for success, GL_FALSE for failure (singular matrix)
*/
static GLboolean invert_matrix( const GLdouble *m, GLdouble *out )
{
/* NB. OpenGL Matrices are COLUMN major. */
#define SWAP_ROWS(a, b) { GLdouble *_tmp = a; (a)=(b); (b)=_tmp; }
#define MAT(m,r,c) (m)[(c)*4+(r)]
GLdouble wtmp[4][8];
GLdouble m0, m1, m2, m3, s;
GLdouble *r0, *r1, *r2, *r3;
r0 = wtmp[0], r1 = wtmp[1], r2 = wtmp[2], r3 = wtmp[3];
r0[0] = MAT(m,0,0), r0[1] = MAT(m,0,1),
r0[2] = MAT(m,0,2), r0[3] = MAT(m,0,3),
r0[4] = 1.0, r0[5] = r0[6] = r0[7] = 0.0,
r1[0] = MAT(m,1,0), r1[1] = MAT(m,1,1),
r1[2] = MAT(m,1,2), r1[3] = MAT(m,1,3),
r1[5] = 1.0, r1[4] = r1[6] = r1[7] = 0.0,
r2[0] = MAT(m,2,0), r2[1] = MAT(m,2,1),
r2[2] = MAT(m,2,2), r2[3] = MAT(m,2,3),
r2[6] = 1.0, r2[4] = r2[5] = r2[7] = 0.0,
r3[0] = MAT(m,3,0), r3[1] = MAT(m,3,1),
r3[2] = MAT(m,3,2), r3[3] = MAT(m,3,3),
r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0;
/* choose pivot - or die */
if (fabs(r3[0])>fabs(r2[0])) SWAP_ROWS(r3, r2);
if (fabs(r2[0])>fabs(r1[0])) SWAP_ROWS(r2, r1);
if (fabs(r1[0])>fabs(r0[0])) SWAP_ROWS(r1, r0);
if (0.0 == r0[0]) return GL_FALSE;
/* eliminate first variable */
m1 = r1[0]/r0[0]; m2 = r2[0]/r0[0]; m3 = r3[0]/r0[0];
s = r0[1]; r1[1] -= m1 * s; r2[1] -= m2 * s; r3[1] -= m3 * s;
s = r0[2]; r1[2] -= m1 * s; r2[2] -= m2 * s; r3[2] -= m3 * s;
s = r0[3]; r1[3] -= m1 * s; r2[3] -= m2 * s; r3[3] -= m3 * s;
s = r0[4];
if (s != 0.0) { r1[4] -= m1 * s; r2[4] -= m2 * s; r3[4] -= m3 * s; }
s = r0[5];
if (s != 0.0) { r1[5] -= m1 * s; r2[5] -= m2 * s; r3[5] -= m3 * s; }
s = r0[6];
if (s != 0.0) { r1[6] -= m1 * s; r2[6] -= m2 * s; r3[6] -= m3 * s; }
s = r0[7];
if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; }
/* choose pivot - or die */
if (fabs(r3[1])>fabs(r2[1])) SWAP_ROWS(r3, r2);
if (fabs(r2[1])>fabs(r1[1])) SWAP_ROWS(r2, r1);
if (0.0 == r1[1]) return GL_FALSE;
/* eliminate second variable */
m2 = r2[1]/r1[1]; m3 = r3[1]/r1[1];
r2[2] -= m2 * r1[2]; r3[2] -= m3 * r1[2];
r2[3] -= m2 * r1[3]; r3[3] -= m3 * r1[3];
s = r1[4]; if (0.0 != s) { r2[4] -= m2 * s; r3[4] -= m3 * s; }
s = r1[5]; if (0.0 != s) { r2[5] -= m2 * s; r3[5] -= m3 * s; }
s = r1[6]; if (0.0 != s) { r2[6] -= m2 * s; r3[6] -= m3 * s; }
s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; }
/* choose pivot - or die */
if (fabs(r3[2])>fabs(r2[2])) SWAP_ROWS(r3, r2);
if (0.0 == r2[2]) return GL_FALSE;
/* eliminate third variable */
m3 = r3[2]/r2[2];
r3[3] -= m3 * r2[3], r3[4] -= m3 * r2[4],
r3[5] -= m3 * r2[5], r3[6] -= m3 * r2[6],
r3[7] -= m3 * r2[7];
/* last check */
if (0.0 == r3[3]) return GL_FALSE;
s = 1.0/r3[3]; /* now back substitute row 3 */
r3[4] *= s; r3[5] *= s; r3[6] *= s; r3[7] *= s;
m2 = r2[3]; /* now back substitute row 2 */
s = 1.0/r2[2];
r2[4] = s * (r2[4] - r3[4] * m2), r2[5] = s * (r2[5] - r3[5] * m2),
r2[6] = s * (r2[6] - r3[6] * m2), r2[7] = s * (r2[7] - r3[7] * m2);
m1 = r1[3];
r1[4] -= r3[4] * m1, r1[5] -= r3[5] * m1,
r1[6] -= r3[6] * m1, r1[7] -= r3[7] * m1;
m0 = r0[3];
r0[4] -= r3[4] * m0, r0[5] -= r3[5] * m0,
r0[6] -= r3[6] * m0, r0[7] -= r3[7] * m0;
m1 = r1[2]; /* now back substitute row 1 */
s = 1.0/r1[1];
r1[4] = s * (r1[4] - r2[4] * m1), r1[5] = s * (r1[5] - r2[5] * m1),
r1[6] = s * (r1[6] - r2[6] * m1), r1[7] = s * (r1[7] - r2[7] * m1);
m0 = r0[2];
r0[4] -= r2[4] * m0, r0[5] -= r2[5] * m0,
r0[6] -= r2[6] * m0, r0[7] -= r2[7] * m0;
m0 = r0[1]; /* now back substitute row 0 */
s = 1.0/r0[0];
r0[4] = s * (r0[4] - r1[4] * m0), r0[5] = s * (r0[5] - r1[5] * m0),
r0[6] = s * (r0[6] - r1[6] * m0), r0[7] = s * (r0[7] - r1[7] * m0);
MAT(out,0,0) = r0[4]; MAT(out,0,1) = r0[5],
MAT(out,0,2) = r0[6]; MAT(out,0,3) = r0[7],
MAT(out,1,0) = r1[4]; MAT(out,1,1) = r1[5],
MAT(out,1,2) = r1[6]; MAT(out,1,3) = r1[7],
MAT(out,2,0) = r2[4]; MAT(out,2,1) = r2[5],
MAT(out,2,2) = r2[6]; MAT(out,2,3) = r2[7],
MAT(out,3,0) = r3[4]; MAT(out,3,1) = r3[5],
MAT(out,3,2) = r3[6]; MAT(out,3,3) = r3[7];
return GL_TRUE;
#undef MAT
#undef SWAP_ROWS
}
GLint UnProject(GLdouble winx,GLdouble winy,GLdouble winz,
const GLdouble model[16],const GLdouble proj[16],
const GLint viewport[4],
GLdouble *objx,GLdouble *objy,GLdouble *objz)
{
/* matrice de transformation */
GLdouble m[16], A[16];
GLdouble in[4],out[4];
/* transformation coordonnees normalisees entre -1 et 1 */
in[0]=(winx-viewport[0])*2/viewport[2] - 1.0;
in[1]=(winy-viewport[1])*2/viewport[3] - 1.0;
in[2]=2*winz - 1.0;
in[3]=1.0;
/* calcul transformation inverse */
matmul(A,proj,model);
invert_matrix(A,m);
/* d'ou les coordonnees objets */
transform_point(out,m,in);
if (out[3]==0.0)
return GL_FALSE;
*objx=out[0]/out[3];
*objy=out[1]/out[3];
*objz=out[2]/out[3];
return GL_TRUE;
}
void CPortalsRender::Draw3D()
{
if(!portals.show_3d || portals.portal_count < 1)
return;
g_QglTable.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);
double cam[3];
double proj_m[16];
double model_m[16];
float min_check[3];
float max_check[3];
float trans = (100.0f - portals.trans_3d) / 100.0f;
int view[4];
g_QglTable.m_pfn_qglGetDoublev(GL_PROJECTION_MATRIX, proj_m);
g_QglTable.m_pfn_qglGetDoublev(GL_MODELVIEW_MATRIX, model_m);
g_QglTable.m_pfn_qglGetIntegerv(GL_VIEWPORT, view);
UnProject(0.5 * (double)view[2], 0.5 * (double)view[3], 0.0, model_m, proj_m, view, cam, cam+1, cam+2);
min_check[0] = (float)cam[0] + (portals.clip_range * 64.0f);
min_check[1] = (float)cam[1] + (portals.clip_range * 64.0f);
min_check[2] = (float)cam[2] + (portals.clip_range * 64.0f);
max_check[0] = (float)cam[0] - (portals.clip_range * 64.0f);
max_check[1] = (float)cam[1] - (portals.clip_range * 64.0f);
max_check[2] = (float)cam[2] - (portals.clip_range * 64.0f);
g_QglTable.m_pfn_qglHint(GL_FOG_HINT, GL_NICEST);
g_QglTable.m_pfn_qglDisable(GL_CULL_FACE);
g_QglTable.m_pfn_qglDisable(GL_LINE_SMOOTH);
g_QglTable.m_pfn_qglDisable(GL_POLYGON_SMOOTH);
g_QglTable.m_pfn_qglPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
g_QglTable.m_pfn_qglShadeModel(GL_SMOOTH);
g_QglTable.m_pfn_qglEnable(GL_BLEND);
g_QglTable.m_pfn_qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
g_QglTable.m_pfn_qglEnable(GL_POLYGON_SMOOTH);
if(portals.aa_3d)
g_QglTable.m_pfn_qglEnable(GL_LINE_SMOOTH);
else
g_QglTable.m_pfn_qglDisable(GL_LINE_SMOOTH);
if(portals.fog)
{
g_QglTable.m_pfn_qglEnable(GL_FOG);
g_QglTable.m_pfn_qglFogi(GL_FOG_MODE, GL_EXP);
g_QglTable.m_pfn_qglFogf(GL_FOG_DENSITY, 0.001f);
g_QglTable.m_pfn_qglFogf(GL_FOG_START, 10.0f);
g_QglTable.m_pfn_qglFogf(GL_FOG_END, 10000.0f);
g_QglTable.m_pfn_qglFogi(GL_FOG_INDEX, 0);
g_QglTable.m_pfn_qglFogfv(GL_FOG_COLOR, portals.fp_color_fog);
}
else
{
g_QglTable.m_pfn_qglDisable(GL_FOG);
}
switch(portals.zbuffer)
{
case 1:
g_QglTable.m_pfn_qglEnable(GL_DEPTH_TEST);
g_QglTable.m_pfn_qglDepthMask(GL_FALSE);
break;
case 2:
g_QglTable.m_pfn_qglDisable(GL_DEPTH_TEST);
break;
default:
g_QglTable.m_pfn_qglEnable(GL_DEPTH_TEST);
g_QglTable.m_pfn_qglDepthMask(GL_TRUE);
}
g_QglTable.m_pfn_qglLineWidth(portals.width_3d * 0.5f);
unsigned int n, p;
if(portals.polygons)
{
if(portals.zbuffer != 0)
{
float d;
for(n = 0; n < portals.portal_count; n++)
{
d = (float)cam[0] - portals.portal[n].center.p[0];
portals.portal[n].dist = d * d;
d = (float)cam[1] - portals.portal[n].center.p[1];
portals.portal[n].dist += d * d;
d = (float)cam[2] - portals.portal[n].center.p[2];
portals.portal[n].dist += d * d;
portals.portal_sort[n] = n;
}
qsort(portals.portal_sort, portals.portal_count, 4, compare);
for(n = 0; n < portals.portal_count; n++)
{
if(portals.polygons == 2 && !portals.portal[portals.portal_sort[n]].hint)
continue;
if(portals.clip)
{
if(min_check[0] < portals.portal[portals.portal_sort[n]].min[0])
continue;
else if(min_check[1] < portals.portal[portals.portal_sort[n]].min[1])
continue;
else if(min_check[2] < portals.portal[portals.portal_sort[n]].min[2])
continue;
else if(max_check[0] > portals.portal[portals.portal_sort[n]].max[0])
continue;
else if(max_check[1] > portals.portal[portals.portal_sort[n]].max[1])
continue;
else if(max_check[2] > portals.portal[portals.portal_sort[n]].max[2])
continue;
}
g_QglTable.m_pfn_qglColor4f(portals.portal[portals.portal_sort[n]].fp_color_random[0], portals.portal[portals.portal_sort[n]].fp_color_random[1],
portals.portal[portals.portal_sort[n]].fp_color_random[2], trans);
g_QglTable.m_pfn_qglBegin(GL_POLYGON);
for(p = 0; p < portals.portal[portals.portal_sort[n]].point_count; p++)
g_QglTable.m_pfn_qglVertex3fv(portals.portal[portals.portal_sort[n]].point[p].p);
g_QglTable.m_pfn_qglEnd();
}
}
else
{
for(n = 0; n < portals.portal_count; n++)
{
if(portals.polygons == 2 && !portals.portal[n].hint)
continue;
if(portals.clip)
{
if(min_check[0] < portals.portal[n].min[0])
continue;
else if(min_check[1] < portals.portal[n].min[1])
continue;
else if(min_check[2] < portals.portal[n].min[2])
continue;
else if(max_check[0] > portals.portal[n].max[0])
continue;
else if(max_check[1] > portals.portal[n].max[1])
continue;
else if(max_check[2] > portals.portal[n].max[2])
continue;
}
g_QglTable.m_pfn_qglColor4f(portals.portal[n].fp_color_random[0], portals.portal[n].fp_color_random[1],
portals.portal[n].fp_color_random[2], trans);
g_QglTable.m_pfn_qglBegin(GL_POLYGON);
for(p = 0; p < portals.portal[n].point_count; p++)
g_QglTable.m_pfn_qglVertex3fv(portals.portal[n].point[p].p);
g_QglTable.m_pfn_qglEnd();
}
}
}
if(portals.lines)
{
g_QglTable.m_pfn_qglColor4fv(portals.fp_color_3d);
for(n = 0; n < portals.portal_count; n++)
{
if(portals.lines == 2 && !portals.portal[n].hint)
continue;
if(portals.clip)
{
if(min_check[0] < portals.portal[n].min[0])
continue;
else if(min_check[1] < portals.portal[n].min[1])
continue;
else if(min_check[2] < portals.portal[n].min[2])
continue;
else if(max_check[0] > portals.portal[n].max[0])
continue;
else if(max_check[1] > portals.portal[n].max[1])
continue;
else if(max_check[2] > portals.portal[n].max[2])
continue;
}
g_QglTable.m_pfn_qglBegin(GL_LINE_LOOP);
for(p = 0; p < portals.portal[n].point_count; p++)
g_QglTable.m_pfn_qglVertex3fv(portals.portal[n].inner_point[p].p);
g_QglTable.m_pfn_qglEnd();
}
}
g_QglTable.m_pfn_qglPopAttrib();
}

122
contrib/prtview/portals.h Normal file
View File

@@ -0,0 +1,122 @@
/*
PrtView plugin for GtkRadiant
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _PORTALS_H_
#define _PORTALS_H_
class CBspPoint {
public:
float p[3];
};
class CBspPortal {
public:
CBspPortal();
~CBspPortal();
protected:
public:
CBspPoint center;
unsigned point_count;
CBspPoint *point;
CBspPoint *inner_point;
float fp_color_random[4];
float min[3];
float max[3];
float dist;
bool hint;
bool Build(char *def);
};
class CPortals {
public:
CPortals();
~CPortals();
protected:
public:
void Load(); // use filename in fn
void Purge();
void FixColors();
char fn[PATH_MAX];
int zbuffer;
int polygons;
int lines;
bool show_3d;
bool aa_3d;
bool fog;
COLORREF color_3d;
float width_3d; // in 8'ths
float fp_color_3d[4];
COLORREF color_fog;
float fp_color_fog[4];
float trans_3d;
float clip_range;
bool clip;
bool show_2d;
bool aa_2d;
COLORREF color_2d;
float width_2d; // in 8'ths
float fp_color_2d[4];
CBspPortal *portal;
int *portal_sort;
bool hint_flags;
// CBspNode *node;
unsigned int node_count;
unsigned int portal_count;
};
class CPortalsRender : public IGL2DWindow, public IGL3DWindow {
public:
CPortalsRender();
virtual ~CPortalsRender();
protected:
int refCount;
public:
// IGL2DWindow IGL3DWindow interface
void IncRef() { refCount++; }
void DecRef() { refCount--; if (refCount <= 0) delete this; }
void Draw2D( VIEWTYPE vt );
void Draw3D();
void Register();
};
// void Sys_Printf (char *text, ...);
extern CPortals portals;
extern CPortalsRender render;
#endif // _PORTALS_H_

546
contrib/prtview/prtview.cpp Normal file
View File

@@ -0,0 +1,546 @@
/*
PrtView plugin for GtkRadiant
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// PrtView.cpp : Defines the initialization routines for the DLL.
//
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include "missing.h"
#define Q3R_CMD_SPLITTER "-"
#define Q3R_CMD_ABOUT "About Portal Viewer"
#define Q3R_CMD_LOAD "Load .prt file"
#define Q3R_CMD_RELEASE "Unload .prt file"
#define Q3R_CMD_SHOW_3D "Toggle portals (3D)"
#define Q3R_CMD_SHOW_2D "Toggle portals (2D)"
#define Q3R_CMD_OPTIONS "Configure Portal Viewer"
static char INIfn[PATH_MAX];
/////////////////////////////////////////////////////////////////////////////
// CPrtViewApp construction
#define RENDER_2D "Render2D"
#define WIDTH_2D "Width2D"
#define AA_2D "AntiAlias2D"
#define COLOR_2D "Color2D"
#define RENDER_3D "Render3D"
#define WIDTH_3D "Width3D"
#define AA_3D "AntiAlias3D"
#define COLOR_3D "Color3D"
#define COLOR_FOG "ColorFog"
#define FOG "Fog"
#define ZBUFFER "ZBuffer"
#define POLYGON "Polygons"
#define LINE "Lines"
#define TRANS_3D "Transparency"
#define CLIP_RANGE "ClipRange"
#define CLIP "Clip"
void InitInstance ()
{
#ifdef WIN32
char fn[_MAX_PATH];
char fn_drive[_MAX_DRIVE];
char fn_dir[_MAX_DIR];
char fn_name[_MAX_FNAME];
char fn_ext[_MAX_EXT];
GetModuleFileName(GetModuleHandle("PrtView.dll"), fn, _MAX_PATH);
_splitpath(fn, fn_drive, fn_dir, fn_name, fn_ext);
strcpy(INIfn, fn_drive);
strcat(INIfn, fn_dir);
strcat(INIfn, fn_name);
strcat(INIfn, ".ini");
#else // if def __linux__
strcpy (INIfn, g_get_home_dir ());
strcat (INIfn, "/.radiant/");
strcat (INIfn, RADIANT_VERSION);
strcat (INIfn, "/prtview.ini");
#endif
portals.show_2d = INIGetInt(RENDER_2D, FALSE) ? qtrue : qfalse;
portals.aa_2d = INIGetInt(AA_2D, FALSE) ? qtrue : qfalse;
portals.width_2d = (float)INIGetInt(WIDTH_2D, 10);
portals.color_2d = (COLORREF)INIGetInt(COLOR_2D, RGB(0, 0, 255)) & 0xFFFFFF;
if (portals.width_2d > 40.0f)
portals.width_2d = 40.0f;
else if (portals.width_2d < 2.0f)
portals.width_2d = 2.0f;
portals.show_3d = INIGetInt(RENDER_3D, TRUE) ? qtrue : qfalse;
portals.zbuffer = INIGetInt(ZBUFFER, 1);
portals.fog = INIGetInt(FOG, FALSE) ? qtrue : qfalse;
portals.polygons = INIGetInt(POLYGON, TRUE);
portals.lines = INIGetInt(LINE, TRUE);
portals.aa_3d = INIGetInt(AA_3D, FALSE) ? qtrue : qfalse;
portals.width_3d = (float)INIGetInt(WIDTH_3D, 4);
portals.color_3d = (COLORREF)INIGetInt(COLOR_3D, RGB(255, 255, 0)) & 0xFFFFFF;
portals.color_fog = (COLORREF)INIGetInt(COLOR_FOG, RGB(127, 127, 127)) & 0xFFFFFF;
portals.trans_3d = (float)INIGetInt(TRANS_3D, 50);
portals.clip = INIGetInt(CLIP, FALSE) ? qtrue : qfalse;
portals.clip_range = (float)INIGetInt(CLIP_RANGE, 16);
if (portals.clip_range < 1)
portals.clip_range = 1;
else if (portals.clip_range > 128)
portals.clip_range = 128;
if (portals.zbuffer < 0)
portals.zbuffer = 0;
else if (portals.zbuffer > 2)
portals.zbuffer = 0;
if (portals.width_3d > 40.0f)
portals.width_3d = 40.0f;
else if (portals.width_3d < 2.0f)
portals.width_3d = 2.0f;
if (portals.trans_3d > 100.0f)
portals.trans_3d = 100.0f;
else if (portals.trans_3d < 0.0f)
portals.trans_3d = 0.0f;
SaveConfig();
portals.FixColors();
}
void SaveConfig ()
{
INISetInt(RENDER_2D, portals.show_2d, "Draw in 2D windows");
INISetInt(WIDTH_2D, (int)portals.width_2d, "Width of lines in 2D windows (in units of 1/2)");
INISetInt(COLOR_2D, (int)portals.color_2d, "Color of lines in 2D windows");
INISetInt(AA_2D, portals.aa_2d, "Draw lines in 2D window anti-aliased");
INISetInt(ZBUFFER, portals.zbuffer, "ZBuffer level in 3D window");
INISetInt(FOG, portals.fog, "Use depth cueing in 3D window");
INISetInt(POLYGON, portals.polygons, "Render using polygons polygons in 3D window");
INISetInt(LINE, portals.polygons, "Render using lines in 3D window");
INISetInt(RENDER_3D, portals.show_3d, "Draw in 3D windows");
INISetInt(WIDTH_3D, (int)portals.width_3d, "Width of lines in 3D window (in units of 1/2)");
INISetInt(COLOR_3D, (int)portals.color_3d, "Color of lines/polygons in 3D window");
INISetInt(COLOR_FOG, (int)portals.color_fog, "Color of distant lines/polygons in 3D window");
INISetInt(AA_3D, portals.aa_3d, "Draw lines in 3D window anti-aliased");
INISetInt(TRANS_3D, (int)portals.trans_3d, "Transparency in 3d view (0 = solid, 100 = invisible)");
INISetInt(CLIP, portals.clip, "Cubic clipper active for portal viewer");
INISetInt(CLIP_RANGE, (int)portals.clip_range, "Portal viewer cubic clip distance (in units of 64)");
}
// Radiant function table
// use to access what Radiant provides
_QERFuncTable_1 g_FuncTable;
_QERQglTable g_QglTable;
#define CONFIG_SECTION "Configuration"
#if defined(__linux__) || defined(__APPLE__)
static bool read_var (const char *filename, const char *section, const char *key, char *value)
{
char line[1024], *ptr;
FILE *rc;
rc = fopen (filename, "rt");
if (rc == NULL)
return false;
while (fgets (line, 1024, rc) != 0)
{
// First we find the section
if (line[0] != '[')
continue;
ptr = strchr (line, ']');
*ptr = '\0';
if (strcmp (&line[1], section) == 0)
{
while (fgets (line, 1024, rc) != 0)
{
ptr = strchr (line, '=');
if (ptr == NULL)
{
// reached the end of the section
fclose (rc);
return false;
}
*ptr = '\0';
if (strcmp (line, key) == 0)
{
strcpy (value, ptr+1);
fclose (rc);
while (value[strlen (value)-1] == 10 ||
value[strlen (value)-1] == 13 ||
value[strlen (value)-1] == 32)
value[strlen (value)-1] = 0;
return true;
}
}
}
}
fclose (rc);
return false;
}
static bool save_var (const char *filename, const char *section, const char *key, const char *value)
{
char line[1024], *ptr;
FILE *old_rc = NULL, *rc;
bool found;
rc = fopen (filename, "rb");
if (rc != NULL)
{
guint32 len;
void *buf;
char *tmpname = g_strdup_printf ("%s.tmp", filename);
old_rc = fopen (tmpname, "w+b");
g_free (tmpname);
fseek (rc, 0, SEEK_END);
len = ftell (rc);
rewind (rc);
buf = g_malloc (len);
fread (buf, len, 1, rc);
fwrite (buf, len, 1, old_rc);
g_free (buf);
fclose (rc);
rewind (old_rc);
}
rc = fopen (filename, "wb");
if (rc == NULL)
return false;
// First we need to find the section
found = false;
if (old_rc != NULL)
while (fgets (line, 1024, old_rc) != NULL)
{
fputs (line, rc);
if (line[0] == '[')
{
ptr = strchr (line, ']');
*ptr = '\0';
if (strcmp (&line[1], section) == 0)
{
found = true;
break;
}
}
}
if (!found)
{
fputs ("\n", rc);
fprintf (rc, "[%s]\n", section);
}
fprintf (rc, "%s=%s\n", key, value);
if (old_rc != NULL)
{
while (fgets (line, 1024, old_rc) != NULL)
{
ptr = strchr (line, '=');
if (ptr != NULL)
{
*ptr = '\0';
if (strcmp (line, key) == 0)
break;
*ptr = '=';
fputs (line, rc);
}
else
{
fputs (line, rc);
break;
}
}
while (fgets (line, 1024, old_rc) != NULL)
fputs (line, rc);
fclose (old_rc);
char *tmpname = g_strdup_printf ("%s.tmp", filename);
remove (tmpname);
g_free (tmpname);
}
fclose (rc);
return true;
}
#endif
int INIGetInt(char *key, int def)
{
#if defined(__linux__) || defined(__APPLE__)
char value[1024];
if (read_var (INIfn, CONFIG_SECTION, key, value))
return atoi (value);
else
return def;
#else
return GetPrivateProfileInt(CONFIG_SECTION, key, def, INIfn);
#endif
}
void INISetInt(char *key, int val, char *comment /* = NULL */)
{
char s[1000];
if(comment)
sprintf(s, "%d ; %s", val, comment);
else
sprintf(s, "%d", val);
#if defined(__linux__) || defined(__APPLE__)
save_var (INIfn, CONFIG_SECTION, key, s);
#else
WritePrivateProfileString(CONFIG_SECTION, key, s, INIfn);
#endif
}
// plugin name
static const char *PLUGIN_NAME = "Portal Viewer";
// commands in the menu
static const char *PLUGIN_COMMANDS =
Q3R_CMD_ABOUT ";"
Q3R_CMD_SPLITTER ";"
Q3R_CMD_OPTIONS ";"
Q3R_CMD_SPLITTER ";"
Q3R_CMD_SHOW_2D ";"
Q3R_CMD_SHOW_3D ";"
Q3R_CMD_SPLITTER ";"
Q3R_CMD_RELEASE ";"
Q3R_CMD_LOAD;
extern "C" LPVOID WINAPI QERPlug_GetFuncTable()
{
return &g_FuncTable;
}
//extern "C" LPCSTR WINAPI QERPlug_Init (HMODULE hApp, GtkWidget* hwndMain)
extern "C" const char* QERPlug_Init (void *hApp, void* pMainWidget)
{
// Setup defaults & load config
InitInstance();
return "Portal Viewer for Q3Radiant";
}
extern "C" const char* QERPlug_GetName()
{
return (char*)PLUGIN_NAME;
}
extern "C" const char* QERPlug_GetCommandList()
{
return (char*)PLUGIN_COMMANDS;
}
/*
void Sys_Printf (char *text, ...)
{
va_list argptr;
char buf[32768];
va_start (argptr,text);
vsprintf (buf, text, argptr);
va_end (argptr);
g_FuncTable.m_pfnSysMsg (buf);
}
*/
bool interfaces_started = false;
static void CheckInterfaces()
{
if (interfaces_started)
return;
render.Register();
interfaces_started = true;
}
extern "C" void QERPlug_Dispatch(const char* p, vec3_t vMin, vec3_t vMax, bool bSingleBrush)
{
Sys_Printf (MSG_PREFIX "Command \"%s\"\n",p);
if (!strcmp(p,Q3R_CMD_ABOUT))
{
DoAboutDlg ();
}
else if (!strcmp(p,Q3R_CMD_LOAD))
{
CheckInterfaces();
if (interfaces_started)
{
if (DoLoadPortalFileDialog () == IDOK)
{
portals.Load();
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_ALL);
}
else
{
Sys_Printf(MSG_PREFIX "Portal file load aborted.\n", portals.fn);
}
}
}
else if (!strcmp(p,Q3R_CMD_RELEASE))
{
portals.Purge();
if (interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_ALL);
Sys_Printf(MSG_PREFIX "Portals unloaded.\n");
}
else if (!strcmp(p,Q3R_CMD_SHOW_2D))
{
portals.show_2d = !portals.show_2d;
if(interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_ALL);
SaveConfig();
if(portals.show_2d)
Sys_Printf(MSG_PREFIX "Portals will be rendered in 2D view.\n");
else
Sys_Printf(MSG_PREFIX "Portals will NOT be rendered in 2D view.\n");
}
else if (!strcmp(p,Q3R_CMD_SHOW_3D))
{
portals.show_3d = !portals.show_3d;
SaveConfig();
if (interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_ALL);
if (portals.show_3d)
Sys_Printf(MSG_PREFIX "Portals will be rendered in 3D view.\n");
else
Sys_Printf(MSG_PREFIX "Portals will NOT be rendered in 3D view.\n");
}
else if (!strcmp(p,Q3R_CMD_OPTIONS))
{
DoConfigDialog ();
SaveConfig();
if (interfaces_started)
g_FuncTable.m_pfnSysUpdateWindows(UPDATE_ALL);
}
}
// =============================================================================
// SYNAPSE
#include "synapse.h"
class CSynapseClientPrtView : public CSynapseClient
{
public:
// CSynapseClient API
bool RequestAPI(APIDescriptor_t *pAPI);
const char* GetInfo();
CSynapseClientPrtView() { }
virtual ~CSynapseClientPrtView() { }
};
CSynapseServer* g_pSynapseServer = NULL;
CSynapseClientPrtView g_SynapseClient;
extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const char *version, CSynapseServer *pServer)
{
if (strcmp(version, SYNAPSE_VERSION))
{
Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);
return NULL;
}
g_pSynapseServer = pServer;
g_pSynapseServer->IncRef();
Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());
g_SynapseClient.AddAPI(PLUGIN_MAJOR, PRTVIEW_MINOR, sizeof(_QERPluginTable));
g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(g_FuncTable), SYN_REQUIRE, &g_FuncTable);
g_SynapseClient.AddAPI(QGL_MAJOR, NULL, sizeof(g_QglTable), SYN_REQUIRE, &g_QglTable);
return &g_SynapseClient;
}
bool CSynapseClientPrtView::RequestAPI(APIDescriptor_t *pAPI)
{
if( !strcmp(pAPI->major_name, PLUGIN_MAJOR) )
{
if( !strcmp(pAPI->minor_name, PRTVIEW_MINOR) )
{
_QERPluginTable* pTable= static_cast<_QERPluginTable*>(pAPI->mpTable);
pTable->m_pfnQERPlug_Init = QERPlug_Init;
pTable->m_pfnQERPlug_GetName = QERPlug_GetName;
pTable->m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
pTable->m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
return true;
}
}
Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());
return false;
}
#include "version.h"
const char* CSynapseClientPrtView::GetInfo()
{
return "PrtView module built " __DATE__ " " RADIANT_VERSION;
}

29
contrib/prtview/prtview.h Normal file
View File

@@ -0,0 +1,29 @@
/*
PrtView plugin for GtkRadiant
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// PrtView.h : main header file for the PRTVIEW DLL
//
#if !defined(AFX_PRTVIEW_H__234356A6_1D66_11D4_BFEB_204C4F4F5020__INCLUDED_)
#define AFX_PRTVIEW_H__234356A6_1D66_11D4_BFEB_204C4F4F5020__INCLUDED_
void InitInstance ();
void SaveConfig ();
#endif // !defined(AFX_PRTVIEW_H__234356A6_1D66_11D4_BFEB_204C4F4F5020__INCLUDED_)

View File

@@ -0,0 +1,13 @@
//
// PRTVIEW.RC2 - resources Microsoft Visual C++ does not edit directly
//
#ifdef APSTUDIO_INVOKED
#error this file is not editable by Microsoft Visual C++
#endif //APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
// Add manually edited resources here...
/////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,42 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by PrtView.rc
//
#define IDD_ABOUT 129
#define IDD_LOAD 130
#define IDD_CONFIG 131
#define IDC_LOAD_2D 1000
#define IDC_LOAD_3D 1001
#define IDC_LOAD_FILE_NAME 1002
#define IDC_LOAD_OTHER 1003
#define IDC_CONFIG_3D 1004
#define IDC_CONFIG_2D 1005
#define IDC_SCROLL_2D_WIDTH 1006
#define IDC_2D_WIDTH 1007
#define IDC_ANTI_ALIAS_2D 1008
#define IDC_COLOR_2D 1009
#define IDC_ZBUFFER 1010
#define IDC_SCROLL_3D_WIDTH 1011
#define IDC_3D_WIDTH 1012
#define IDC_ANTI_ALIAS_3D 1013
#define IDC_COLOR_3D 1014
#define IDC_COLOR_FOG 1015
#define IDC_FOG 1016
#define IDC_SCROLL_3D_TRANS 1017
#define IDC_POLY 1018
#define IDC_3D_TRANS 1019
#define IDC_LINES 1020
#define IDC_SCROLL_CUBIC 1021
#define IDC_CUBIC 1022
#define IDC_CLIP 1023
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 133
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1011
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -0,0 +1,25 @@
/*
PrtView plugin for GtkRadiant
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// stdafx.cpp : source file that includes just the standard includes
// PrtView.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

87
contrib/prtview/stdafx.h Normal file
View File

@@ -0,0 +1,87 @@
/*
PrtView plugin for GtkRadiant
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __PRTVIEW_AFX_H__
#define __PRTVIEW_AFX_H__
#include "mathlib.h"
#include <string.h>
#include "qertypes.h"
#include <stdio.h>
#include "iscenegraph.h"
#define USE_QERTABLE_DEFINE
#include "qerplugin.h"
extern _QERFuncTable_1 g_FuncTable;
// plugin
#include "iplugin.h"
#include "ibspfrontend.h"
#include "igl.h"
#include "version.h"
#include <gtk/gtk.h>
#ifdef WIN32
#include <windows.h>
#endif
#if defined(__linux__) || defined(__APPLE__)
#include <GL/glx.h>
typedef guint32 COLORREF;
typedef void* LPVOID;
typedef char* LPCSTR;
typedef void* HMODULE;
typedef int BOOL;
#define RGB(r, g, b) ((guint32)(((guint8) (r) | ((guint16) (g) << 8))|(((guint32) (guint8) (b)) << 16)))
#define GetRValue(rgb) ((guint8)(rgb))
#define GetGValue(rgb) ((guint8)(((guint16)(rgb)) >> 8))
#define GetBValue(rgb) ((guint8)((rgb)>>16))
#define IDOK 1
#define IDCANCEL 2
#endif // __linux__
#define PATH_MAX 260
// PrtView
#include "gtkdlgs.h"
#include "prtview.h"
#include "portals.h"
#define MSG_PREFIX "Portal Viewer plugin: "
#define PRTVIEW_MINOR "prtview"
#define UPDATE_2D (W_XY | W_XZ | W_YZ)
#define UPDATE_3D (W_CAMERA)
#define UPDATE_ALL (UPDATE_2D | UPDATE_3D)
int INIGetInt(char *key, int def);
void INISetInt(char *key, int val, char *comment = NULL);
extern bool interfaces_started;
extern _QERFuncTable_1 g_FuncTable;
extern _QERQglTable g_QglTable;
#endif