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

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

View File

@@ -0,0 +1,318 @@
/*
Copyright (C) 2003 Reed Mideke.
This file is part of GtkRadiant.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//
// bkgrnd2d Plugin
//
// Code by reyalP aka Reed Mideke
//
// Based on various other plugins
//
#include "bkgrnd2d.h"
CBackgroundRender render;
CBackgroundImage backgroundXY(XY),backgroundXZ(XZ),backgroundYZ(YZ);
CBackgroundRender::CBackgroundRender()
{
refCount = 1;
}
CBackgroundRender::~CBackgroundRender()
{
}
void CBackgroundRender::Register()
{
g_QglTable.m_pfnHookGL2DWindow( this );
}
void CBackgroundRender::Draw2D( VIEWTYPE vt )
{
switch(vt)
{
case XY:
backgroundXY.Render();
break;
case XZ:
backgroundXZ.Render();
break;
case YZ:
backgroundYZ.Render();
break;
}
}
CBackgroundImage::CBackgroundImage(VIEWTYPE vt)
{
m_tex = NULL;
m_alpha = 0.5;
// TODO, sensible defaults ? Or not show until we have extents ?
m_xmin = m_ymin = 0.0f;
m_xmax = m_ymax = 0.0f;
m_bActive = false;
m_vt = vt;
switch(m_vt)
{
case XY:
m_ix = 0;
m_iy = 1;
break;
case XZ:
m_ix = 0;
m_iy = 2;
break;
case YZ:
m_ix = 1;
m_iy = 2;
break;
}
}
/*
* should cleanup, but I don't think we can be sure it happens before our
* interfaces are gone
CBackgroundImage::~CBackgroundImage()
{
}
*/
void CBackgroundImage::Cleanup()
{
if(m_tex) {
g_QglTable.m_pfn_qglDeleteTextures(1,&m_tex->texture_number);
g_free(m_tex);
m_tex = NULL;
}
}
void CBackgroundImage::Render()
{
if (!m_bActive || !Valid())
return;
g_QglTable.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);
g_QglTable.m_pfn_qglEnable(GL_TEXTURE_2D);
g_QglTable.m_pfn_qglEnable(GL_BLEND);
g_QglTable.m_pfn_qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
g_QglTable.m_pfn_qglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
g_QglTable.m_pfn_qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
g_QglTable.m_pfn_qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
g_QglTable.m_pfn_qglPolygonMode(GL_FRONT,GL_FILL);
// TODO, just so we can tell if we end up going the wrong way
// g_QglTable.m_pfn_qglPolygonMode(GL_BACK,GL_LINE);
// TODO any other state we should not assume ?
g_QglTable.m_pfn_qglBindTexture(GL_TEXTURE_2D, m_tex->texture_number);
g_QglTable.m_pfn_qglBegin(GL_QUADS);
g_QglTable.m_pfn_qglColor4f(1.0,1.0,1.0,m_alpha);
g_QglTable.m_pfn_qglTexCoord2f(0.0,1.0);
g_QglTable.m_pfn_qglVertex2f(m_xmin,m_ymin);
g_QglTable.m_pfn_qglTexCoord2f(1.0,1.0);
g_QglTable.m_pfn_qglVertex2f(m_xmax,m_ymin);
g_QglTable.m_pfn_qglTexCoord2f(1.0,0.0);
g_QglTable.m_pfn_qglVertex2f(m_xmax,m_ymax);
g_QglTable.m_pfn_qglTexCoord2f(0.0,0.0);
g_QglTable.m_pfn_qglVertex2f(m_xmin,m_ymax);
g_QglTable.m_pfn_qglEnd();
g_QglTable.m_pfn_qglBindTexture(GL_TEXTURE_2D, 0);
g_QglTable.m_pfn_qglPopAttrib();
}
bool CBackgroundImage::Load(const char *filename)
{
qtexture_t *newtex;
unsigned char *image = NULL; // gets allocated with what ? g_malloc
int width = 0, height = 0;
g_FuncTable.m_pfnLoadImage(filename,&image,&width,&height);
if(!image) {
Syn_Printf(MSG_WARN "load %s failed\n",filename);
return false;
}
// just in case we want to build for an old version
// http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=900
#ifdef BKGRND2D_JPG_WORKAROUND
if ( strlen(filename) > 4 && !strcmp(".jpg",filename + strlen(filename) - 4)) {
Syn_Printf(MSG_PREFIX ".jpg workaround, clearing alpha channel\n");
int size = width*height*4;
int i;
for (i = 3; i < size; i+=4) {
image[i] = 255;
}
}
#endif
//TODO bug for stored texture size
//TODO whose gl context are we in, anyway ?
newtex = g_FuncTable.m_pfnLoadTextureRGBA(image,width,height);
g_free(image);
if(!newtex) {
Syn_Printf(MSG_WARN "image to texture failed\n");
return false;
}
Cleanup();
m_tex = newtex;
g_FuncTable.m_pfnSysUpdateWindows(W_XY);
return true;
}
bool CBackgroundImage::SetExtentsMM()
{
entity_s *worldentity;
const char *val;
int xmin = 0, ymin = 0, xmax = 0, ymax = 0;
worldentity = (entity_s *)g_FuncTable.m_pfnGetEntityHandle(0);
if(!worldentity) {
Syn_Printf(MSG_WARN "SetExtentsMM worldspawn not found\n");
return false;
}
//TODO val is not NULL even if key does not exist
val = g_EntityTable.m_pfnValueForKey(worldentity,"mapcoordsmins");
if(!val || !val[0]) {
Syn_Printf(MSG_WARN "SetExtentsMM mapcoordsmins not found\n");
return false;
}
// we could be more robust
// note contortions due to splashs strange idea of min and max
if(sscanf(val, "%d %d",&xmin,&ymax) != 2)
{
Syn_Printf(MSG_WARN "SetExtentsMM mapcoordsmins malformed\n");
return false;
}
val = g_EntityTable.m_pfnValueForKey(worldentity,"mapcoordsmaxs");
if(!val || !val[0]) {
Syn_Printf(MSG_WARN "SetExtentsMM mapcoordsmaxs not found\n");
return false;
}
if(sscanf(val, "%d %d",&xmax,&ymin) != 2)
{
Syn_Printf(MSG_WARN "SetExtentsMM mapcoordsmaxs malformed\n");
return false;
}
//might do sanity check before we commit
m_xmin = (float)xmin;
m_ymin = (float)ymin;
m_xmax = (float)xmax;
m_ymax = (float)ymax;
g_FuncTable.m_pfnSysUpdateWindows(W_XY);
return true;
}
// TODO, this should just be exported from core
// ripped directly from radiant/select.cpp:Select_GetBounds
//
static bool get_selection_bounds (vec3_t mins, vec3_t maxs)
{
brush_t *b;
int i;
brush_t *selected_brushes = g_DataTable.m_pfnSelectedBrushes();
//TODO should never happen
if(!selected_brushes) {
Sys_Printf (MSG_PREFIX "selected_brushes = NULL\n");
return false;
}
// this should mean no selection
if(selected_brushes == selected_brushes->next) {
Sys_Printf (MSG_PREFIX "nothing selected\n");
return false;
}
for (i=0 ; i<3 ; i++)
{
mins[i] = 99999;
maxs[i] = -99999;
}
for (b=selected_brushes->next ; b != selected_brushes ; b=b->next)
{
if (b->owner->eclass->fixedsize)
{
for (i=0 ; i<3 ; i++)
{
if (b->owner->origin[i] < mins[i])
mins[i] = b->owner->origin[i];
if (b->owner->origin[i] > maxs[i])
maxs[i] = b->owner->origin[i];
}
}
else
{
for (i=0 ; i<3 ; i++)
{
if (b->mins[i] < mins[i])
mins[i] = b->mins[i];
if (b->maxs[i] > maxs[i])
maxs[i] = b->maxs[i];
}
}
}
return true;
}
bool CBackgroundImage::SetExtentsSel()
{
vec3_t mins,maxs;
if(!get_selection_bounds(mins,maxs))
return false;
if(((int)mins[m_ix] == (int)maxs[m_ix]) ||
((int)mins[m_iy] == (int)maxs[m_iy])) {
Syn_Printf(MSG_PREFIX "tiny selection\n");
return false;
}
m_xmin = mins[m_ix];
m_ymin = mins[m_iy];
m_xmax = maxs[m_ix];
m_ymax = maxs[m_iy];
g_FuncTable.m_pfnSysUpdateWindows(W_XY);
return true;
}

View File

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

View File

@@ -0,0 +1,133 @@
# Microsoft Developer Studio Project File - Name="bkgrnd2d" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=bkgrnd2d - 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 "bkgrnd2d.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 "bkgrnd2d.mak" CFG="bkgrnd2d - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "bkgrnd2d - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "bkgrnd2d - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "bkgrnd2d - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# 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 CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BKGRND2D_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\shared" /I "..\..\..\libxml2\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" /I "..\..\include" /I "..\common" /I "..\..\libs" /I "..\..\libs\nvtristrip" /I "..\..\..\STLPort\stlport" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BKGRND2D_EXPORTS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 gobject-2.0.lib gdk-win32-2.0.lib gtk-win32-2.0.lib pango-1.0.lib glib-2.0.lib synapse.lib /nologo /dll /machine:I386 /libpath:"..\..\libs\synapse\release" /libpath:"..\..\..\gtk2-win32\lib\\"
!ELSEIF "$(CFG)" == "bkgrnd2d - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# 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 CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BKGRND2D_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\shared" /I "..\..\..\libxml2\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" /I "..\..\include" /I "..\common" /I "..\..\libs" /I "..\..\libs\nvtristrip" /I "..\..\..\STLPort\stlport" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BKGRND2D_EXPORTS" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 gobject-2.0.lib gdk-win32-2.0.lib gtk-win32-2.0.lib pango-1.0.lib glib-2.0.lib synapse.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\..\libs\synapse\debug" /libpath:"..\..\..\gtk2-win32\lib\\"
!ENDIF
# Begin Target
# Name "bkgrnd2d - Win32 Release"
# Name "bkgrnd2d - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\bkgrnd2d.cpp
# End Source File
# Begin Source File
SOURCE=.\bkgrnd2d.def
# End Source File
# Begin Source File
SOURCE=.\dialog.cpp
# End Source File
# Begin Source File
SOURCE=.\plugin.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\bkgrnd2d.h
# End Source File
# Begin Source File
SOURCE=.\dialog.h
# End Source File
# Begin Source File
SOURCE=.\plugin.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,82 @@
/*
Copyright (C) 2003 Reed Mideke.
This file is part of GtkRadiant.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//
// bkgrnd2d Plugin
//
// Code by reyalP aka Reed Mideke
//
// Based on spritemodel source code by hydra
//
#include "plugin.h"
class CBackgroundImage {
private:
qtexture_t *m_tex;
VIEWTYPE m_vt;
// which components of a vec3_t correspond to x and y in the image
unsigned m_ix,m_iy;
public:
CBackgroundImage(VIEWTYPE vt);
// ~CBackgroundImage();
float m_alpha; // vertex alpha
bool m_bActive;
// x and y axis are in relation to the screen, not world, making rendering
// the same for each view type. Whoever sets them is responsible for
// shuffling.
// units are world units.
// TODO should be private
float m_xmin,m_ymin,m_xmax,m_ymax;
// load file, create new tex, cleanup old tex, set new tex
bool Load(const char *filename);
void Cleanup(); // free texture, free tex, set make tex NULL
bool SetExtentsMM(); // set extents by ET mapcoordsmaxs/mapcoordsmins
bool SetExtentsSel(); // set extents by selection
void Render();
bool Valid() { return (m_tex && (m_xmin != m_xmax) && (m_ymin != m_ymax)); }
};
class CBackgroundRender : public IGL2DWindow {
public:
CBackgroundRender();
virtual ~CBackgroundRender();
protected:
int refCount;
public:
// IGL2DWindow IGL3DWindow interface
void IncRef() { refCount++; }
void DecRef() { refCount--; if (refCount <= 0) delete this; }
void Draw2D( VIEWTYPE vt );
void Register();
};
extern CBackgroundImage backgroundXY,backgroundXZ,backgroundYZ;
extern CBackgroundRender render;

View File

@@ -0,0 +1,171 @@
<?xml version="1.0" encoding = "Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.00"
Name="bkgrnd2d"
ProjectGUID="{356A36AA-1F10-48A0-BF63-227DFB46F208}"
>
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\shared,..\..\..\libxml2\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,..\..\include,..\common,..\..\libs,..\..\libs\nvtristrip,..\..\..\STLPort\stlport"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;BKGRND2D_EXPORTS"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Release/bkgrnd2d.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="gobject-2.0.lib gdk-win32-2.0.lib gtk-win32-2.0.lib pango-1.0.lib glib-2.0.lib synapse.lib"
OutputFile=".\Release/bkgrnd2d.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\..\libs\synapse\release,..\..\..\gtk2-win32\lib\"
ModuleDefinitionFile=".\bkgrnd2d.def"
ProgramDatabaseFile=".\Release/bkgrnd2d.pdb"
ImportLibrary=".\Release/bkgrnd2d.lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Release/bkgrnd2d.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\shared,..\..\..\libxml2\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,..\..\include,..\common,..\..\libs,..\..\libs\nvtristrip,..\..\..\STLPort\stlport"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;BKGRND2D_EXPORTS"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Debug/bkgrnd2d.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="gobject-2.0.lib gdk-win32-2.0.lib gtk-win32-2.0.lib pango-1.0.lib glib-2.0.lib synapse.lib"
OutputFile=".\Debug/bkgrnd2d.dll"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\..\libs\synapse\debug,..\..\..\gtk2-win32\lib\"
ModuleDefinitionFile=".\bkgrnd2d.def"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\Debug/bkgrnd2d.pdb"
ImportLibrary=".\Debug/bkgrnd2d.lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Debug/bkgrnd2d.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
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=".\bkgrnd2d.cpp">
</File>
<File
RelativePath=".\bkgrnd2d.def">
</File>
<File
RelativePath=".\dialog.cpp">
</File>
<File
RelativePath=".\plugin.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath=".\bkgrnd2d.h">
</File>
<File
RelativePath=".\dialog.h">
</File>
<File
RelativePath=".\plugin.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

364
contrib/bkgrnd2d/dialog.cpp Normal file
View File

@@ -0,0 +1,364 @@
/*
Copyright (C) 2003 Reed Mideke.
This file is part of GtkRadiant.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//
// bkgrnd2d Plugin dialog
//
// Code by reyalP aka Reed Mideke
//
// Based on various other plugins
//
#include <gtk/gtk.h>
#include "bkgrnd2d.h"
#include "dialog.h"
// spaces to make label nice and big
#define NO_FILE_MSG " (no file loaded) "
static GtkWidget *pDialogWnd;
static GtkWidget *pNotebook;
static GtkTooltips *pTooltips;
class CBackgroundDialogPage
{
private:
GtkWidget *m_pWidget;
GtkWidget *m_pTabLabel;
GtkWidget *m_pFileLabel;
GtkWidget *m_pPosLabel;
VIEWTYPE m_vt;
bool m_bValidFile;
public:
CBackgroundImage *m_pImage;
CBackgroundDialogPage( VIEWTYPE vt );
void Append(GtkWidget *notebook);
void Browse();
void Reload();
void SetPosLabel();
// ~BackgroundDialogPage();
};
// dialog page callbacks
static void browse_callback( GtkWidget *widget, gpointer data )
{
((CBackgroundDialogPage *)data)->Browse();
}
static void reload_callback( GtkWidget *widget, gpointer data )
{
((CBackgroundDialogPage *)data)->Reload();
}
static void size_sel_callback( GtkWidget *widget, gpointer data )
{
CBackgroundDialogPage *pPage = (CBackgroundDialogPage *)data;
if (pPage->m_pImage->SetExtentsSel())
pPage->SetPosLabel();
}
static void size_mm_callback( GtkWidget *widget, gpointer data )
{
CBackgroundDialogPage *pPage = (CBackgroundDialogPage *)data;
if(pPage->m_pImage->SetExtentsMM())
pPage->SetPosLabel();
}
static void alpha_adjust_callback( GtkWidget *widget, gpointer data )
{
CBackgroundDialogPage *pPage = (CBackgroundDialogPage *)data;
pPage->m_pImage->m_alpha = (float)gtk_range_get_value (GTK_RANGE(widget));
g_FuncTable.m_pfnSysUpdateWindows(W_XY);
}
void CBackgroundDialogPage::Reload()
{
if(m_bValidFile)
m_pImage->Load(gtk_label_get_text(GTK_LABEL(m_pFileLabel)));
}
void CBackgroundDialogPage::Browse()
{
char browsedir[PATH_MAX];
const char *ct;
const char *newfile;
char *t;
//TODO GetMapName saves the map. eeep!
//also with no map, returns unnamed.map, otherwise returns full path
// Syn_Printf(MSG_PREFIX "GetMapName() %s\n",
// g_FuncTable.m_pfnGetMapName());
ct = g_FuncTable.m_pfnReadProjectKey("basepath");
// TODO shouldn't need this stuff
if(!ct || !strlen(ct)) {
Syn_Printf(MSG_PREFIX "basepath = NULL or empty\n");
return;
}
Syn_Printf(MSG_PREFIX "basepath: %s\n",ct);
if(strlen(ct) >= PATH_MAX) {
Syn_Printf(MSG_PREFIX "base game dir too long\n");
return;
}
strcpy(browsedir,ct);
// make sure we have a trailing /
if(browsedir[strlen(browsedir) - 1] != '/')
strcat(browsedir,"/");
//if we dont have a file yet, don't try to use it for default dir
if(m_bValidFile) {
// filename should always be a nice clean unix style relative path
ct = gtk_label_get_text(GTK_LABEL(m_pFileLabel));
strcat(browsedir,ct);
Syn_Printf(MSG_PREFIX "full path: %s\n",browsedir);
// lop off the file part
t = browsedir + strlen(browsedir) - 1;
while (t != browsedir && *t != '/')
t--;
*t = 0;
}
Syn_Printf(MSG_PREFIX "browse directory %s\n",browsedir);
//does NOT need freeing contrary to include/qerplugin.h comments
//TODO bug/patch for comments
//TODO patern gets fucked up sometimes if empty
//http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=915
newfile = g_FuncTable.m_pfnFileDialog(pDialogWnd,TRUE,
"Load Background Image",browsedir,FILETYPE_KEY);
if(!newfile) {
Syn_Printf(MSG_PREFIX "newfile = NULL\n");
return;
}
Syn_Printf(MSG_PREFIX "newfile: %s\n",newfile);
newfile = g_FileSystemTable.m_pfnExtractRelativePath(newfile);
if(!newfile) {
Syn_Printf(MSG_PREFIX "newfile = NULL\n");
return;
}
Syn_Printf(MSG_PREFIX "newfile: %s\n",newfile);
if(m_pImage->Load(newfile)) {
m_bValidFile = true;
gtk_label_set_text(GTK_LABEL(m_pFileLabel),newfile);
}
}
void CBackgroundDialogPage::SetPosLabel()
{
char s[64];
// TODO no snprintf ?
sprintf(s, "Size/Position (%d,%d) (%d,%d)",(int)(m_pImage->m_xmin),
(int)(m_pImage->m_ymin),(int)(m_pImage->m_xmax),(int)(m_pImage->m_ymax));
gtk_label_set_text(GTK_LABEL(m_pPosLabel),s);
}
CBackgroundDialogPage::CBackgroundDialogPage(VIEWTYPE vt )
{
GtkWidget *frame;
GtkWidget *hbox;
GtkWidget *w;
m_vt = vt;
m_bValidFile = false;
switch(m_vt)
{
case XY:
m_pTabLabel = gtk_label_new("X/Y");
m_pImage = &backgroundXY;
break;
case XZ:
m_pTabLabel = gtk_label_new("X/Z");
m_pImage = &backgroundXZ;
break;
case YZ:
m_pTabLabel = gtk_label_new("Y/Z");
m_pImage = &backgroundYZ;
break;
}
// A vbox to hold everything
m_pWidget = gtk_vbox_new(FALSE,0);
// Frame for file row
frame = gtk_frame_new("File");
gtk_box_pack_start (GTK_BOX (m_pWidget),frame, FALSE, FALSE, 2);
// hbox for first row
hbox = gtk_hbox_new(FALSE,5);
gtk_container_set_border_width(GTK_CONTAINER (hbox),4);
gtk_container_add (GTK_CONTAINER (frame), hbox);
// label to display filename
m_pFileLabel = gtk_label_new(NO_FILE_MSG);
gtk_label_set_selectable(GTK_LABEL(m_pFileLabel),TRUE);
//TODO set min size ? done with spaces right now
gtk_box_pack_start (GTK_BOX (hbox),m_pFileLabel, TRUE, TRUE, 5);
gtk_widget_show (m_pFileLabel);
w = gtk_button_new_with_label ("Browse...");
g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (browse_callback),
(gpointer)this);
gtk_box_pack_start (GTK_BOX (hbox),w, FALSE, FALSE, 5);
gtk_tooltips_set_tip (pTooltips, w, "Select a file", NULL);
gtk_widget_show (w);
w = gtk_button_new_with_label ("Reload");
g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (reload_callback),
(gpointer)this);
// TODO disable until we have file
// gtk_widget_set_sensitive(w,FALSE);
gtk_tooltips_set_tip (pTooltips, w, "Reload current file", NULL);
gtk_box_pack_start (GTK_BOX (hbox),w, FALSE, FALSE, 5);
gtk_widget_show (w);
gtk_widget_show (hbox);
gtk_widget_show (frame);
// second row (rendering options)
frame = gtk_frame_new("Rendering");
gtk_box_pack_start (GTK_BOX (m_pWidget),frame, FALSE, FALSE, 2);
hbox = gtk_hbox_new(FALSE,5);
gtk_container_set_border_width(GTK_CONTAINER (hbox),4);
gtk_container_add (GTK_CONTAINER (frame), hbox);
w = gtk_label_new("Vertex alpha:");
gtk_box_pack_start (GTK_BOX (hbox),w, FALSE, FALSE, 5);
gtk_widget_show (w);
w = gtk_hscale_new_with_range(0.0,1.0,0.01);
gtk_range_set_value(GTK_RANGE(w),0.5);
gtk_scale_set_value_pos(GTK_SCALE(w),GTK_POS_LEFT);
g_signal_connect (G_OBJECT (w), "value-changed",
G_CALLBACK (alpha_adjust_callback), (gpointer)this);
gtk_box_pack_start (GTK_BOX (hbox),w, TRUE, TRUE, 5);
gtk_tooltips_set_tip (pTooltips, w, "Set image transparancy", NULL);
gtk_widget_show (w);
gtk_widget_show (hbox);
gtk_widget_show (frame);
// Third row (size and position)
frame = gtk_frame_new("Size/Position (undefined)");
m_pPosLabel = gtk_frame_get_label_widget (GTK_FRAME(frame));
gtk_box_pack_start ( GTK_BOX (m_pWidget), frame, FALSE, FALSE, 2);
hbox = gtk_hbox_new(FALSE,5);
gtk_container_add (GTK_CONTAINER (frame), hbox);
gtk_container_set_border_width(GTK_CONTAINER (hbox),4);
w = gtk_button_new_with_label ("from selection");
gtk_box_pack_start (GTK_BOX (hbox),w, TRUE, FALSE, 5);
g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (size_sel_callback),
(gpointer)this);
gtk_tooltips_set_tip (pTooltips, w, "Set the size of the image to the bounding rectangle of all selected brushes and entities", NULL);
gtk_widget_show (w);
if(m_vt == XY) {
w = gtk_button_new_with_label ("from map mins/maxs");
gtk_box_pack_start ( GTK_BOX (hbox),w, TRUE, FALSE, 2);
g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (size_mm_callback),
(gpointer)this);
gtk_tooltips_set_tip (pTooltips, w, "Set the size of the image using the mapcoordsmins and mapcoordsmaxs keys of the worldspawn entity", NULL);
gtk_widget_show (w);
}
gtk_widget_show (hbox);
gtk_widget_show (frame);
gtk_widget_show ( m_pWidget );
}
void CBackgroundDialogPage::Append(GtkWidget *notebook)
{
gtk_notebook_append_page( GTK_NOTEBOOK(notebook), m_pWidget, m_pTabLabel);
}
// dialog global callbacks
/*
static gint expose_callback( GtkWidget *widget, gpointer data )
{
return FALSE;
}
*/
static void response_callback( GtkWidget *widget, gint response, gpointer data )
{
if( response == GTK_RESPONSE_CLOSE )
gtk_widget_hide( pDialogWnd );
}
static gint close_callback( GtkWidget *widget, gpointer data )
{
gtk_widget_hide( pDialogWnd );
return TRUE;
}
void InitBackgroundDialog()
{
CBackgroundDialogPage *pPage;
pDialogWnd = gtk_dialog_new_with_buttons ("Background Images",
GTK_WINDOW(g_pMainWidget),
(GtkDialogFlags)(GTK_DIALOG_DESTROY_WITH_PARENT),
// TODO dialog with no buttons
// GTK_STOCK_CLOSE,
// GTK_RESPONSE_CLOSE,
NULL);
gtk_signal_connect( GTK_OBJECT (pDialogWnd), "delete_event",
GTK_SIGNAL_FUNC( close_callback ), NULL );
gtk_signal_connect( GTK_OBJECT (pDialogWnd), "response",
GTK_SIGNAL_FUNC( response_callback ), NULL );
// gtk_signal_connect( GTK_OBJECT (pDialogWnd), "expose_event", GTK_SIGNAL_FUNC( ci_expose ), NULL );
pTooltips = gtk_tooltips_new();
pNotebook = gtk_notebook_new();
pPage = new CBackgroundDialogPage(XY);
pPage->Append(pNotebook);
pPage = new CBackgroundDialogPage(XZ);
pPage->Append(pNotebook);
pPage = new CBackgroundDialogPage(YZ);
pPage->Append(pNotebook);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG(pDialogWnd)->vbox), pNotebook, TRUE, TRUE, 0);
gtk_widget_show ( pNotebook );
gtk_widget_realize( pDialogWnd );
}
void ShowBackgroundDialog()
{
gtk_window_present( GTK_WINDOW(pDialogWnd) );
}
void ShowBackgroundDialogPG(int page)
{
gtk_notebook_set_current_page(GTK_NOTEBOOK(pNotebook),page);
ShowBackgroundDialog();
}

35
contrib/bkgrnd2d/dialog.h Normal file
View File

@@ -0,0 +1,35 @@
/*
Copyright (C) 2003 Reed Mideke.
This file is part of GtkRadiant.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//
// bkgrnd2d Plugin dialog box
//
// Code by reyalP aka Reed Mideke
//
//
#ifndef _BKGRND2D_DIALOG_H_
#define _BKGRND2D_DIALOG_H_
void InitBackgroundDialog();
void ShowBackgroundDialog();
void ShowBackgroundDialogPG(int page);
#endif // _BKGRND2D_DIALOG_H_

319
contrib/bkgrnd2d/plugin.cpp Normal file
View File

@@ -0,0 +1,319 @@
/*
Copyright (C) 2003 Reed Mideke.
This file is part of GtkRadiant.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//
// 2d background Plugin
//
// Code by reyalP aka Reed Mideke
//
// Based on
//
/*
Overview
========
This little plugin allows you to display an image in the background of the
gtkradiant XY window.
Version History
===============
v0.1
- Initial version.
v0.2
- three views, dialog box, toolbar
v0.25
- tooltips, follow gtkradiant coding conventions
Why ?
-----
http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=88
How ?
-----
- textures 'n widgets 'n stuff.
*/
//#include "plugin.h"
//TODO we just poke the objects directly
#include "bkgrnd2d.h"
#include "dialog.h"
#define CMD_SEP "-"
#define CMD_CONFIG "Configure..."
#define CMD_ABOUT "About..."
// =============================================================================
// Globals
// function tables
_QERFuncTable_1 g_FuncTable;
_QERQglTable g_QglTable;
_QERFileSystemTable g_FileSystemTable;
_QEREntityTable g_EntityTable;
_QERAppDataTable g_DataTable;
// for the file load dialog
void *g_pMainWidget;
// =============================================================================
// plugin implementation
static const char *PLUGIN_NAME = "2d window background plugin";
//backwards for some reason
static const char *PLUGIN_COMMANDS = CMD_ABOUT ";"
CMD_SEP ";"
CMD_CONFIG
;
static const char *PLUGIN_ABOUT = "2d window background v0.25\n\n"
"By reyalP (hellsownpuppy@yahoo.com)";
void DoBkgrndToggleXY();
void DoBkgrndToggleXZ();
void DoBkgrndToggleYZ();
#define NUM_TOOLBAR_BUTTONS 4
struct toolbar_button_info_s
{
char *image;
char *text;
char *tip;
void (*func)();
IToolbarButton::EType type;
};
struct toolbar_button_info_s toolbar_buttons[NUM_TOOLBAR_BUTTONS] =
{
{
"bkgrnd2d_xy_toggle.bmp",
"xy background",
"Toggle xy background image",
DoBkgrndToggleXY,
IToolbarButton::eToggleButton
},
{
"bkgrnd2d_xz_toggle.bmp",
"xz background",
"Toggle xz background image",
DoBkgrndToggleXZ,
IToolbarButton::eToggleButton
},
{
"bkgrnd2d_yz_toggle.bmp",
"yz background",
"Toggle yz background image",
DoBkgrndToggleYZ,
IToolbarButton::eToggleButton
},
{
"bkgrnd2d_conf.bmp",
"Configure",
"Configure background images",
ShowBackgroundDialog,
IToolbarButton::eButton
},
};
class Bkgrnd2dButton : public IToolbarButton
{
public:
const toolbar_button_info_s *bi;
virtual const char* getImage() const
{
return bi->image;
}
virtual const char* getText() const
{
return bi->text;
}
virtual const char* getTooltip() const
{
return bi->tip;
}
virtual void activate() const
{
bi->func();
return ;
}
virtual EType getType() const
{
return bi->type;
}
};
Bkgrnd2dButton g_bkgrnd2dbuttons[NUM_TOOLBAR_BUTTONS];
unsigned int ToolbarButtonCount()
{
return NUM_TOOLBAR_BUTTONS;
}
const IToolbarButton* GetToolbarButton(unsigned int index)
{
g_bkgrnd2dbuttons[index].bi = &toolbar_buttons[index];
return &g_bkgrnd2dbuttons[index];
}
extern "C" const char* QERPlug_Init (void *hApp, void* pMainWidget)
{
g_pMainWidget = pMainWidget;
InitBackgroundDialog();
render.Register();
//TODO is it right ? is it wrong ? it works
//TODO figure out supported image types
GetFileTypeRegistry()->addType(FILETYPE_KEY, filetype_t("all files", "*.*"));
GetFileTypeRegistry()->addType(FILETYPE_KEY, filetype_t("jpeg files", "*.jpg"));
GetFileTypeRegistry()->addType(FILETYPE_KEY, filetype_t("targa files", "*.tga"));
return (char *) PLUGIN_NAME;
}
extern "C" const char* QERPlug_GetName ()
{
return (char *) PLUGIN_NAME;
}
extern "C" const char* QERPlug_GetCommandList ()
{
return (char *) PLUGIN_COMMANDS;
}
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, CMD_ABOUT)) {
g_FuncTable.m_pfnMessageBox(NULL, PLUGIN_ABOUT, "About", MB_OK, NULL);
}
else if(!strcmp(p,CMD_CONFIG)) {
ShowBackgroundDialog();
}
}
//TODO these three suck
void DoBkgrndToggleXY()
{
Sys_Printf (MSG_PREFIX "DoBkgrndToggleXY\n");
// always toggle, since the buttons do
backgroundXY.m_bActive = (backgroundXY.m_bActive) ? false:true;
// if we don't have image or extents, and we activated,
// bring up the dialog with the corresponding page
// would be better to hide or grey out button, but we can't
if(backgroundXY.m_bActive && !backgroundXY.Valid())
ShowBackgroundDialogPG(0);
else
g_FuncTable.m_pfnSysUpdateWindows(W_XY);
}
void DoBkgrndToggleXZ()
{
Sys_Printf (MSG_PREFIX "DoBkgrndToggleXZ\n");
backgroundXZ.m_bActive = (backgroundXZ.m_bActive) ? false:true;
if(backgroundXZ.m_bActive && !backgroundXZ.Valid())
ShowBackgroundDialogPG(1);
else
g_FuncTable.m_pfnSysUpdateWindows(W_XY);
}
void DoBkgrndToggleYZ()
{
Sys_Printf (MSG_PREFIX "DoBkgrndToggleYZ\n");
backgroundYZ.m_bActive = (backgroundYZ.m_bActive) ? false:true;
if(backgroundYZ.m_bActive && !backgroundYZ.Valid())
ShowBackgroundDialogPG(2);
else
g_FuncTable.m_pfnSysUpdateWindows(W_XY);
}
// =============================================================================
// SYNAPSE
CSynapseServer* g_pSynapseServer = NULL;
CSynapseClientBkgrnd2d 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(TOOLBAR_MAJOR, BKGRND2D_MINOR, sizeof(_QERPlugToolbarTable));
g_SynapseClient.AddAPI(PLUGIN_MAJOR, BKGRND2D_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 );
// TODO is this the right way to ask for 'whichever VFS we have loaded' ? Seems to work
// for misc filename functions
g_SynapseClient.AddAPI( VFS_MAJOR, "*", sizeof( g_FileSystemTable ), SYN_REQUIRE, &g_FileSystemTable );
// get worldspawn
g_SynapseClient.AddAPI( ENTITY_MAJOR, NULL, sizeof( g_EntityTable ), SYN_REQUIRE, &g_EntityTable );
// selected brushes
g_SynapseClient.AddAPI( DATA_MAJOR, NULL, sizeof( g_DataTable ), SYN_REQUIRE, &g_DataTable );
return &g_SynapseClient;
}
bool CSynapseClientBkgrnd2d::RequestAPI(APIDescriptor_t *pAPI)
{
if (!strcmp(pAPI->major_name, PLUGIN_MAJOR))
{
_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;
}
if (!strcmp(pAPI->major_name, TOOLBAR_MAJOR))
{
_QERPlugToolbarTable* pTable= static_cast<_QERPlugToolbarTable*>(pAPI->mpTable);
pTable->m_pfnToolbarButtonCount = &ToolbarButtonCount;
pTable->m_pfnGetToolbarButton = &GetToolbarButton;
return true;
}
Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());
return false;
}
#include "version.h"
const char* CSynapseClientBkgrnd2d::GetInfo()
{
return "2d Background plugin built " __DATE__ " " RADIANT_VERSION;
}
const char* CSynapseClientBkgrnd2d::GetName()
{
return "bkgrnd2d";
}

79
contrib/bkgrnd2d/plugin.h Normal file
View File

@@ -0,0 +1,79 @@
/*
Copyright (C) 2003 Reed Mideke.
This file is part of GtkRadiant.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//
// bkgrnd2d Plugin
//
// Code by reyalP aka Reed Mideke
//
// Based on spritemodel source code by hydra
//
#ifndef _PLUGIN_H_
#define _PLUGIN_H_
/*!
\todo need general notice about lib purpose etc.
and the external dependencies (such as GLib, STL, mathlib etc.)
*/
#include <stdio.h>
// for CPtrArray for idata.h
#include "missing.h"
#include "synapse.h"
#include "iplugin.h"
#include "itoolbar.h"
#define USE_QERTABLE_DEFINE
#include "qerplugin.h"
#include "igl.h"
#include "ifilesystem.h"
#include "ientity.h"
#include "idata.h"
// verbose messages
#define BKGRND2D_DEBUG
extern _QERFuncTable_1 g_FuncTable;
extern _QERQglTable g_QglTable;
extern _QERFileSystemTable g_FileSystemTable;
extern _QEREntityTable g_EntityTable;
extern _QERAppDataTable g_DataTable;
extern void *g_pMainWidget;
extern CSynapseServer* g_pSynapseServer;
class CSynapseClientBkgrnd2d : public CSynapseClient
{
public:
// CSynapseClient API
bool RequestAPI(APIDescriptor_t *pAPI);
const char* GetInfo();
const char* GetName();
CSynapseClientBkgrnd2d() { }
virtual ~CSynapseClientBkgrnd2d() { }
};
#define MSG_PREFIX "bkgrnd2d: "
#define MSG_WARN "bkgrnd2d WARNING: "
#define BKGRND2D_MINOR "bkgrnd2d"
#define FILETYPE_KEY "bkgrnd2d"
#endif // _PLUGIN_H_

View File

@@ -0,0 +1,131 @@
November 25 2003
bkgrnd2d v 0.25 beta for radiant 1.3.13
by SCDS_reyalP (email hellsownpuppy@yahoo.com)
WARNING:
This is an beta release. It is provided with absolutely NO WARRANTY.
If it turns your data to mush and melts your CPU, don't blame me.
Overview:
This little plugin allows you to display an image in the the gtkradiant 2d
windows. This is useful for layout sketches, maps made from
existing plans, building geometry based on photgraphs, viewing terrain
alphamaps in relation to your terrain, and so on.
Installation:
extract the .dll and bitmaps into your gtkradiant/plugins directory, and
restart radiant. Be sure to use directory names, to ensure the bitmaps go
in your plugins/bitmaps directory.
Uninstallation:
Close radiant, delete the bkgrnd2d.dll from the plugins directory, and
delete the bkgrnd2*.bmp files from the plugins/bitmaps directory.
User Interface:
- The plugin adds 4 buttons to the radiant plugin toolbar. The first 3
toggle the display of a background image in the specified view. The fourth
brings up a configuration dialog. The configuration dialog can also be
opened from the plugins menu.
- If an image has not been loaded, or it's display size and location have
not been set, pushing one of the toggle buttons will bring up the dialog
with the corresponding page selected.
- The configuration dialog is non-modal, meaning that you can leave it open
while you work in radiant. If it gets lost behind another window, clicking
on the configuration button will bring it to the forground.
Usage:
- bring up the configuration dialog.
- Choose the "Browse..." button. This will prompt you for an image file.
The file *MUST* be inside your basegame directory (baseq3, main, etmain or
whatever your chosen game uses). The image must be in a format supported by
the game in use. For q3 based games this is truecolor .jpg, .tga and
sometimes .png. For q2 this is .wal
- Use one of the following methods to set the size (in game units) that the
file is displayed.
1) select 1 or more brushes or entities and choose "from selection"
This will use the total dimensions off all selected brushes and entities
to size the image.
2) For the X/Y view only, choose 'Size to min/max keys' This will look in
the worldspawn entity for the keys mapcoordsmins and mapcoordsmaxs (also
used for ET tracemap generation and command map sizing) and use those
dimensions to size the image.
- Use the toggle buttons to show or hide the loaded images. The buttons will
press or unpress whenever you click them, but an image will only be
displayed once you have successfully loaded a file and set its size/postion.
- Set the opacity of the image using the slider in the configuration dialog.
- If any of these commands do not produce the expected results, there may be
an information in the radiant console. Please include this when reporting
bugs.
Notes and limitations:
- This plugin is compiled for GtkRadiant 1.3.13. It may or may not work with
later versions. It will *NOT* work with version 1.3.12 and below. If you
build from source (see below) you can build it for other versions.
- As mentioned above, the image *MUST* be inside your basegame directory, or
another directory in which radiant looks for game files.
- To prevent the image from being distorted, you should size it to the
original images aspect ratio. mapcoordsmaxs/mapcoordsmins and command maps
should always be square.
- If you want a specific pixel to world unit relationship, you must arrange
that yourself.
- On load, the image is converted to a texture whose dimensions are powers
of 2. If the original image dimensions are not powers of 2, some detail will
be lost due to resampling. If it is too large to fit on a single texture,
resolution is reduced.
- radiants gamma and mipmap options are applied to the image.
- If the image has an alpha channel, it will be included in the blending
process. 0 is transparent, 255 is opaque. .tga images are recommended if
you want to have an alpha channel.
- since the plugin will only use true color files, you cannot use a terrain
indexmap (aka alphamap) or heightmap directly. You can of course, save a
copy of your indexmap in a 32 bit format.
- There is no unload command.
- You put the plugin in a game specific plugin directory, rather than the
radiant plugin directory.
- You cannot set the image size with sub-unit precision.
- Only win32 binaries are included. The source is available from:
http://www.cyberonic.net/~gdevault/rfm/mapstuff/bkgrnd2d-b0.25-src.zip
If you want to use it on another platform you will need a buildable gtkradiant
source tree to build it. For any non-windows platform you will also have to
figure out the compile options. I suggest ripping those off from some other
plugin.
TODO:
- make file selection paterns match supported filetypes
- large images without downsampling
- bitmap and pcx support for indexmaps
- automatic size from indexmapped entities
- render under the grid instead of blending
- mac/*nix support
- remember/save/restore settings
- texture options independant of radiant prefs
- clean up icky code
Changes from 0.1
- all 2d views supported
- new ui
- file selection patterns, default directory improved
Changes from 0.2
- tooltips in dialog
- various code cleanup