fixed eol-style
authorspog <spog>
Tue, 21 Feb 2006 21:09:05 +0000 (21:09 +0000)
committerspog <spog>
Tue, 21 Feb 2006 21:09:05 +0000 (21:09 +0000)
git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@22 8a3a26a2-13c4-0310-b231-cf6edde360e5

contrib/bkgrnd2d/bkgrnd2d.cpp
contrib/bkgrnd2d/dialog.cpp
contrib/bkgrnd2d/plugin.cpp
libs/container/stack.cpp

index 8f96c97..36cf45e 100644 (file)
-/*\r
-Copyright (C) 2003 Reed Mideke.\r
-\r
-This file is part of GtkRadiant.\r
-\r
-GtkRadiant is free software; you can redistribute it and/or modify\r
-it under the terms of the GNU General Public License as published by\r
-the Free Software Foundation; either version 2 of the License, or\r
-(at your option) any later version.\r
-\r
-GtkRadiant is distributed in the hope that it will be useful,\r
-but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-GNU General Public License for more details.\r
-\r
-You should have received a copy of the GNU General Public License\r
-along with GtkRadiant; if not, write to the Free Software\r
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
-*/\r
-\r
-//\r
-// bkgrnd2d Plugin\r
-//\r
-// Code by reyalP aka Reed Mideke\r
-//\r
-// Based on various other plugins\r
-//\r
-\r
-#include "bkgrnd2d.h"\r
-\r
-CBackgroundRender render;\r
-\r
-CBackgroundImage backgroundXY(XY),backgroundXZ(XZ),backgroundYZ(YZ);\r
-\r
-CBackgroundRender::CBackgroundRender()\r
-{\r
-       refCount = 1;\r
-}\r
-\r
-CBackgroundRender::~CBackgroundRender()\r
-{\r
-}\r
-\r
-void CBackgroundRender::Register()\r
-{\r
-       g_QglTable.m_pfnHookGL2DWindow( this );\r
-}\r
-\r
-void CBackgroundRender::Draw2D( VIEWTYPE vt )\r
-{\r
-       switch(vt)\r
-       {\r
-       case XY:\r
-               backgroundXY.Render();\r
-               break;\r
-       case XZ:\r
-               backgroundXZ.Render();\r
-               break;\r
-       case YZ:\r
-               backgroundYZ.Render();\r
-               break;\r
-       }\r
-}\r
-\r
-\r
-CBackgroundImage::CBackgroundImage(VIEWTYPE vt)\r
-{\r
-       m_tex = NULL;\r
-       m_alpha = 0.5;\r
-\r
-       // TODO, sensible defaults ? Or not show until we have extents ?\r
-       m_xmin = m_ymin = 0.0f;\r
-       m_xmax = m_ymax = 0.0f;\r
-\r
-       m_bActive = false;\r
-\r
-       m_vt = vt;\r
-\r
-       switch(m_vt)\r
-       {\r
-               case XY:\r
-                       m_ix = 0;\r
-                       m_iy = 1;\r
-                       break;\r
-               case XZ:\r
-                       m_ix = 0;\r
-                       m_iy = 2;\r
-                       break;\r
-               case YZ:\r
-                       m_ix = 1;\r
-                       m_iy = 2;\r
-                       break;\r
-       }\r
-}\r
-\r
-/*\r
- * should cleanup, but I don't think we can be sure it happens before our \r
- * interfaces are gone\r
-CBackgroundImage::~CBackgroundImage()\r
-{\r
-}\r
-*/\r
-\r
-void CBackgroundImage::Cleanup()\r
-{\r
-       if(m_tex) {\r
-               g_QglTable.m_pfn_qglDeleteTextures(1,&m_tex->texture_number);\r
-               g_free(m_tex);\r
-               m_tex = NULL;\r
-       }\r
-}\r
-\r
-void CBackgroundImage::Render()\r
-{\r
-       if (!m_bActive || !Valid())\r
-               return;\r
-       g_QglTable.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);\r
-\r
-       g_QglTable.m_pfn_qglEnable(GL_TEXTURE_2D);\r
-       g_QglTable.m_pfn_qglEnable(GL_BLEND);\r
-       g_QglTable.m_pfn_qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);\r
-       g_QglTable.m_pfn_qglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);\r
-       g_QglTable.m_pfn_qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);\r
-       g_QglTable.m_pfn_qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);\r
-\r
-       g_QglTable.m_pfn_qglPolygonMode(GL_FRONT,GL_FILL);\r
-       // TODO, just so we can tell if we end up going the wrong way\r
-       // g_QglTable.m_pfn_qglPolygonMode(GL_BACK,GL_LINE);\r
-       // TODO any other state we should not assume ?\r
-\r
-       g_QglTable.m_pfn_qglBindTexture(GL_TEXTURE_2D, m_tex->texture_number);\r
-       g_QglTable.m_pfn_qglBegin(GL_QUADS);\r
-\r
-       g_QglTable.m_pfn_qglColor4f(1.0,1.0,1.0,m_alpha);\r
-       g_QglTable.m_pfn_qglTexCoord2f(0.0,1.0);\r
-       g_QglTable.m_pfn_qglVertex2f(m_xmin,m_ymin);\r
-\r
-       g_QglTable.m_pfn_qglTexCoord2f(1.0,1.0);\r
-       g_QglTable.m_pfn_qglVertex2f(m_xmax,m_ymin);\r
-\r
-       g_QglTable.m_pfn_qglTexCoord2f(1.0,0.0);\r
-       g_QglTable.m_pfn_qglVertex2f(m_xmax,m_ymax);\r
-\r
-       g_QglTable.m_pfn_qglTexCoord2f(0.0,0.0);\r
-       g_QglTable.m_pfn_qglVertex2f(m_xmin,m_ymax);\r
-\r
-       g_QglTable.m_pfn_qglEnd();\r
-       g_QglTable.m_pfn_qglBindTexture(GL_TEXTURE_2D, 0);\r
-\r
-       g_QglTable.m_pfn_qglPopAttrib();\r
-}\r
-\r
-bool CBackgroundImage::Load(const char *filename)\r
-{\r
-       qtexture_t *newtex;\r
-       \r
-       unsigned char *image = NULL; // gets allocated with what ? g_malloc\r
-       int width = 0, height = 0;\r
-\r
-       g_FuncTable.m_pfnLoadImage(filename,&image,&width,&height);\r
-\r
-       if(!image) {\r
-               Syn_Printf(MSG_WARN "load %s failed\n",filename);\r
-               return false;\r
-       }\r
-\r
-// just in case we want to build for an old version\r
-// http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=900\r
-#ifdef BKGRND2D_JPG_WORKAROUND\r
-       if ( strlen(filename) > 4 && !strcmp(".jpg",filename + strlen(filename) - 4)) {\r
-               Syn_Printf(MSG_PREFIX ".jpg workaround, clearing alpha channel\n");\r
-               int size = width*height*4;\r
-               int i;\r
-               for (i = 3; i < size; i+=4) {\r
-                       image[i] = 255;\r
-               }\r
-       }\r
-#endif\r
-       \r
-       //TODO bug for stored texture size\r
-       //TODO whose gl context are we in, anyway ?\r
-       newtex = g_FuncTable.m_pfnLoadTextureRGBA(image,width,height);\r
-\r
-       g_free(image);\r
-\r
-       if(!newtex) {\r
-               Syn_Printf(MSG_WARN "image to texture failed\n");\r
-               return false;\r
-       }\r
-\r
-       Cleanup();\r
-       m_tex = newtex;\r
-\r
-       g_FuncTable.m_pfnSysUpdateWindows(W_XY);\r
-\r
-       return true;\r
-}\r
-\r
-bool CBackgroundImage::SetExtentsMM()\r
-{\r
-       entity_s *worldentity;\r
-       const char *val;\r
-       int xmin = 0, ymin = 0, xmax = 0, ymax = 0;\r
-\r
-       worldentity = (entity_s *)g_FuncTable.m_pfnGetEntityHandle(0);\r
-       if(!worldentity) {\r
-               Syn_Printf(MSG_WARN "SetExtentsMM worldspawn not found\n");\r
-               return false;\r
-       }\r
-       //TODO val is not NULL even if key does not exist\r
-       val = g_EntityTable.m_pfnValueForKey(worldentity,"mapcoordsmins");\r
-       if(!val || !val[0]) {\r
-               Syn_Printf(MSG_WARN "SetExtentsMM mapcoordsmins not found\n");\r
-               return false;\r
-       }\r
-// we could be more robust\r
-// note contortions due to splashs strange idea of min and max\r
-       if(sscanf(val, "%d %d",&xmin,&ymax) != 2)\r
-       {\r
-               Syn_Printf(MSG_WARN "SetExtentsMM mapcoordsmins malformed\n");\r
-               return false;\r
-       }\r
-\r
-       val = g_EntityTable.m_pfnValueForKey(worldentity,"mapcoordsmaxs");\r
-       if(!val || !val[0]) {\r
-               Syn_Printf(MSG_WARN "SetExtentsMM mapcoordsmaxs not found\n");\r
-               return false;\r
-       }\r
-       if(sscanf(val, "%d %d",&xmax,&ymin) != 2)\r
-       {\r
-               Syn_Printf(MSG_WARN "SetExtentsMM mapcoordsmaxs malformed\n");\r
-               return false;\r
-       }\r
-       //might do sanity check before we commit\r
-       m_xmin = (float)xmin;\r
-       m_ymin = (float)ymin;\r
-       m_xmax = (float)xmax;\r
-       m_ymax = (float)ymax;\r
-\r
-       g_FuncTable.m_pfnSysUpdateWindows(W_XY);\r
-       return true;\r
-}\r
-\r
-// TODO, this should just be exported from core\r
-// ripped directly from radiant/select.cpp:Select_GetBounds\r
-//\r
-static bool get_selection_bounds (vec3_t mins, vec3_t maxs)\r
-{\r
-       brush_t *b;\r
-       int             i;\r
-       brush_t *selected_brushes = g_DataTable.m_pfnSelectedBrushes();\r
-       //TODO should never happen\r
-       if(!selected_brushes) {\r
-         Sys_Printf (MSG_PREFIX "selected_brushes = NULL\n"); \r
-         return false;\r
-       }\r
-       // this should mean no selection\r
-       if(selected_brushes == selected_brushes->next) {\r
-         Sys_Printf (MSG_PREFIX "nothing selected\n"); \r
-\r
-         return false;\r
-       }\r
-\r
-       for (i=0 ; i<3 ; i++)\r
-       {\r
-               mins[i] = 99999;\r
-               maxs[i] = -99999;\r
-       }\r
-\r
-       for (b=selected_brushes->next ; b != selected_brushes ; b=b->next)\r
-       {\r
-               if (b->owner->eclass->fixedsize)\r
-               {\r
-                       for (i=0 ; i<3 ; i++)\r
-                       {\r
-                               if (b->owner->origin[i] < mins[i])\r
-                                       mins[i] = b->owner->origin[i];\r
-                               if (b->owner->origin[i] > maxs[i])\r
-                                       maxs[i] = b->owner->origin[i];\r
-                       }\r
-               }\r
-               else\r
-               {\r
-                       for (i=0 ; i<3 ; i++)\r
-                       {\r
-                               if (b->mins[i] < mins[i])\r
-                                       mins[i] = b->mins[i];\r
-                               if (b->maxs[i] > maxs[i])\r
-                                       maxs[i] = b->maxs[i];\r
-                       }\r
-               }\r
-       }\r
-  return true;\r
-}\r
-\r
-bool CBackgroundImage::SetExtentsSel()\r
-{\r
-       vec3_t mins,maxs;\r
-\r
-       if(!get_selection_bounds(mins,maxs)) \r
-               return false;\r
-\r
-       if(((int)mins[m_ix] == (int)maxs[m_ix]) ||\r
-     ((int)mins[m_iy] == (int)maxs[m_iy])) {\r
-               Syn_Printf(MSG_PREFIX "tiny selection\n");\r
-               return false;\r
-       }\r
-\r
-       m_xmin = mins[m_ix];\r
-       m_ymin = mins[m_iy];\r
-       m_xmax = maxs[m_ix];\r
-       m_ymax = maxs[m_iy];\r
-\r
-       g_FuncTable.m_pfnSysUpdateWindows(W_XY);\r
-\r
-  return true;\r
-}\r
-\r
+/*
+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;
+}
+
index 02f39cc..8d9a845 100644 (file)
-/*\r
-Copyright (C) 2003 Reed Mideke.\r
-\r
-This file is part of GtkRadiant.\r
-\r
-GtkRadiant is free software; you can redistribute it and/or modify\r
-it under the terms of the GNU General Public License as published by\r
-the Free Software Foundation; either version 2 of the License, or\r
-(at your option) any later version.\r
-\r
-GtkRadiant is distributed in the hope that it will be useful,\r
-but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-GNU General Public License for more details.\r
-\r
-You should have received a copy of the GNU General Public License\r
-along with GtkRadiant; if not, write to the Free Software\r
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
-*/\r
-\r
-//\r
-// bkgrnd2d Plugin dialog\r
-//\r
-// Code by reyalP aka Reed Mideke\r
-//\r
-// Based on various other plugins\r
-//\r
-\r
-#include <gtk/gtk.h>\r
-\r
-#include "bkgrnd2d.h"\r
-#include "dialog.h"\r
-\r
-// spaces to make label nice and big\r
-#define NO_FILE_MSG "        (no file loaded)        "\r
-\r
-static GtkWidget *pDialogWnd;\r
-static GtkWidget *pNotebook;\r
-static GtkTooltips *pTooltips;\r
-\r
-class CBackgroundDialogPage\r
-{\r
-private:\r
-       GtkWidget *m_pWidget;\r
-       GtkWidget *m_pTabLabel;\r
-       GtkWidget *m_pFileLabel;\r
-       GtkWidget *m_pPosLabel;\r
-       VIEWTYPE m_vt;\r
-       bool m_bValidFile;\r
-\r
-public:\r
-       CBackgroundImage *m_pImage;\r
-       CBackgroundDialogPage( VIEWTYPE vt );\r
-       void Append(GtkWidget *notebook);\r
-       void Browse();\r
-       void Reload();\r
-       void SetPosLabel();\r
-//  ~BackgroundDialogPage();\r
-};\r
-\r
-\r
-// dialog page callbacks\r
-static void browse_callback( GtkWidget *widget, gpointer data )\r
-{\r
-       ((CBackgroundDialogPage *)data)->Browse();\r
-}\r
-\r
-static void reload_callback( GtkWidget *widget, gpointer data )\r
-{\r
-       ((CBackgroundDialogPage *)data)->Reload();\r
-}\r
-\r
-static void size_sel_callback( GtkWidget *widget, gpointer data )\r
-{\r
-       CBackgroundDialogPage *pPage = (CBackgroundDialogPage *)data;\r
-       if (pPage->m_pImage->SetExtentsSel())\r
-               pPage->SetPosLabel();\r
-}\r
-\r
-static void size_mm_callback( GtkWidget *widget, gpointer data )\r
-{\r
-       CBackgroundDialogPage *pPage = (CBackgroundDialogPage *)data;\r
-       if(pPage->m_pImage->SetExtentsMM())\r
-               pPage->SetPosLabel();\r
-}\r
-\r
-static void alpha_adjust_callback( GtkWidget *widget, gpointer data )\r
-{\r
-       CBackgroundDialogPage *pPage = (CBackgroundDialogPage *)data;\r
-       pPage->m_pImage->m_alpha = (float)gtk_range_get_value (GTK_RANGE(widget));\r
-       g_FuncTable.m_pfnSysUpdateWindows(W_XY);\r
-}\r
-\r
-void CBackgroundDialogPage::Reload()\r
-{\r
-       if(m_bValidFile)\r
-               m_pImage->Load(gtk_label_get_text(GTK_LABEL(m_pFileLabel)));\r
-}\r
-\r
-void CBackgroundDialogPage::Browse()\r
-{\r
-       char browsedir[PATH_MAX];\r
-       const char *ct;\r
-       const char *newfile;\r
-       char *t;\r
-       \r
-       //TODO GetMapName saves the map. eeep!\r
-       //also with no map, returns unnamed.map, otherwise returns full path\r
-//     Syn_Printf(MSG_PREFIX "GetMapName() %s\n",\r
-//                             g_FuncTable.m_pfnGetMapName());\r
-       \r
-       ct = g_FuncTable.m_pfnReadProjectKey("basepath");\r
-       // TODO shouldn't need this stuff\r
-       if(!ct || !strlen(ct)) {\r
-               Syn_Printf(MSG_PREFIX "basepath = NULL or empty\n");\r
-               return;\r
-       }\r
-       Syn_Printf(MSG_PREFIX "basepath: %s\n",ct);\r
-       if(strlen(ct) >= PATH_MAX) {\r
-               Syn_Printf(MSG_PREFIX "base game dir too long\n");\r
-               return;\r
-       }\r
-\r
-       strcpy(browsedir,ct);\r
-       // make sure we have a trailing / \r
-       if(browsedir[strlen(browsedir) - 1] != '/')\r
-               strcat(browsedir,"/");\r
-\r
-       //if we dont have a file yet, don't try to use it for default dir\r
-       if(m_bValidFile) {\r
-       // filename should always be a nice clean unix style relative path\r
-               ct = gtk_label_get_text(GTK_LABEL(m_pFileLabel));\r
-               strcat(browsedir,ct);\r
-               Syn_Printf(MSG_PREFIX "full path: %s\n",browsedir);\r
-\r
-               // lop off the file part\r
-               t = browsedir + strlen(browsedir) - 1;\r
-               while (t != browsedir && *t != '/') \r
-                       t--;\r
-               *t = 0;\r
-       }\r
-       Syn_Printf(MSG_PREFIX "browse directory %s\n",browsedir);\r
-       \r
-//does NOT need freeing contrary to include/qerplugin.h comments\r
-//TODO bug/patch for comments\r
-//TODO patern gets fucked up sometimes if empty\r
-//http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=915\r
-       newfile = g_FuncTable.m_pfnFileDialog(pDialogWnd,TRUE,\r
-                                                                 "Load Background Image",browsedir,FILETYPE_KEY);\r
-       if(!newfile) {\r
-               Syn_Printf(MSG_PREFIX "newfile = NULL\n");\r
-               return;\r
-       }\r
-       Syn_Printf(MSG_PREFIX "newfile: %s\n",newfile);\r
-       newfile = g_FileSystemTable.m_pfnExtractRelativePath(newfile);\r
-\r
-       if(!newfile) {\r
-               Syn_Printf(MSG_PREFIX "newfile = NULL\n");\r
-               return;\r
-       }\r
-       Syn_Printf(MSG_PREFIX "newfile: %s\n",newfile);\r
-\r
-       if(m_pImage->Load(newfile)) {\r
-               m_bValidFile = true;\r
-               gtk_label_set_text(GTK_LABEL(m_pFileLabel),newfile);\r
-       }\r
-}\r
-\r
-void CBackgroundDialogPage::SetPosLabel()\r
-{\r
-       char s[64];\r
-       // TODO no snprintf ?\r
-       sprintf(s, "Size/Position (%d,%d) (%d,%d)",(int)(m_pImage->m_xmin),\r
-                       (int)(m_pImage->m_ymin),(int)(m_pImage->m_xmax),(int)(m_pImage->m_ymax));\r
-       gtk_label_set_text(GTK_LABEL(m_pPosLabel),s);\r
-}\r
-\r
-CBackgroundDialogPage::CBackgroundDialogPage(VIEWTYPE vt )\r
-{\r
-       GtkWidget *frame;\r
-       GtkWidget *hbox;\r
-       GtkWidget *w;\r
-\r
-       m_vt = vt;\r
-\r
-       m_bValidFile = false;\r
-\r
-       switch(m_vt)\r
-       {\r
-               case XY:\r
-                       m_pTabLabel = gtk_label_new("X/Y");\r
-                       m_pImage = &backgroundXY;\r
-                       break;\r
-               case XZ:\r
-                       m_pTabLabel = gtk_label_new("X/Z");\r
-                       m_pImage = &backgroundXZ;\r
-                       break;\r
-               case YZ:\r
-                       m_pTabLabel = gtk_label_new("Y/Z");\r
-                       m_pImage = &backgroundYZ;\r
-                       break;\r
-       }\r
-// A vbox to hold everything\r
-       m_pWidget = gtk_vbox_new(FALSE,0); \r
-// Frame for file row\r
-       frame = gtk_frame_new("File");\r
-       gtk_box_pack_start (GTK_BOX (m_pWidget),frame, FALSE, FALSE, 2);\r
-\r
-// hbox for first row\r
-       hbox = gtk_hbox_new(FALSE,5);\r
-       gtk_container_set_border_width(GTK_CONTAINER (hbox),4);\r
-       gtk_container_add (GTK_CONTAINER (frame), hbox);\r
-\r
-// label to display filename\r
-       m_pFileLabel  = gtk_label_new(NO_FILE_MSG);\r
-       gtk_label_set_selectable(GTK_LABEL(m_pFileLabel),TRUE);\r
-//TODO set min size ? done with spaces right now\r
-       gtk_box_pack_start (GTK_BOX (hbox),m_pFileLabel, TRUE, TRUE, 5);\r
-\r
-  gtk_widget_show (m_pFileLabel);\r
-\r
-       w = gtk_button_new_with_label ("Browse...");\r
-       g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (browse_callback),\r
-                                                              (gpointer)this);\r
-       gtk_box_pack_start (GTK_BOX (hbox),w, FALSE, FALSE, 5);\r
-       gtk_tooltips_set_tip (pTooltips, w, "Select a file", NULL);\r
-  gtk_widget_show (w);\r
-       \r
-       w = gtk_button_new_with_label ("Reload");\r
-       g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (reload_callback),\r
-                                                              (gpointer)this);\r
-       // TODO disable until we have file\r
-       // gtk_widget_set_sensitive(w,FALSE);\r
-       gtk_tooltips_set_tip (pTooltips, w, "Reload current file", NULL);\r
-       gtk_box_pack_start (GTK_BOX (hbox),w, FALSE, FALSE, 5);\r
-  gtk_widget_show (w);\r
-\r
-       gtk_widget_show (hbox);\r
-       gtk_widget_show (frame);\r
-\r
-// second row (rendering options)\r
-       frame = gtk_frame_new("Rendering");\r
-       gtk_box_pack_start (GTK_BOX (m_pWidget),frame, FALSE, FALSE, 2);\r
-\r
-       hbox = gtk_hbox_new(FALSE,5);\r
-       gtk_container_set_border_width(GTK_CONTAINER (hbox),4);\r
-       gtk_container_add (GTK_CONTAINER (frame), hbox);\r
-\r
-       w = gtk_label_new("Vertex alpha:");\r
-       gtk_box_pack_start (GTK_BOX (hbox),w, FALSE, FALSE, 5);\r
-  gtk_widget_show (w);\r
-\r
-       w = gtk_hscale_new_with_range(0.0,1.0,0.01);\r
-       gtk_range_set_value(GTK_RANGE(w),0.5);\r
-       gtk_scale_set_value_pos(GTK_SCALE(w),GTK_POS_LEFT);\r
-       g_signal_connect (G_OBJECT (w), "value-changed",\r
-                          G_CALLBACK (alpha_adjust_callback), (gpointer)this);\r
-       gtk_box_pack_start (GTK_BOX (hbox),w, TRUE, TRUE, 5);\r
-       gtk_tooltips_set_tip (pTooltips, w, "Set image transparancy", NULL);\r
-  gtk_widget_show (w);\r
-\r
-       gtk_widget_show (hbox);\r
-       gtk_widget_show (frame);\r
-// Third row (size and position)\r
-       frame = gtk_frame_new("Size/Position (undefined)");\r
-       m_pPosLabel = gtk_frame_get_label_widget (GTK_FRAME(frame));\r
-       gtk_box_pack_start ( GTK_BOX (m_pWidget), frame, FALSE, FALSE, 2);\r
-\r
-       hbox = gtk_hbox_new(FALSE,5);\r
-       gtk_container_add (GTK_CONTAINER (frame), hbox);\r
-       gtk_container_set_border_width(GTK_CONTAINER (hbox),4);\r
-\r
-       w = gtk_button_new_with_label ("from selection");\r
-       gtk_box_pack_start (GTK_BOX (hbox),w, TRUE, FALSE, 5);\r
-       g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (size_sel_callback),\r
-                                                                (gpointer)this);\r
-       gtk_tooltips_set_tip (pTooltips, w, "Set the size of the image to the bounding rectangle of all selected brushes and entities", NULL);\r
-  gtk_widget_show (w);\r
-\r
-       if(m_vt == XY) {\r
-               w = gtk_button_new_with_label ("from map mins/maxs");\r
-               gtk_box_pack_start ( GTK_BOX (hbox),w, TRUE, FALSE, 2);\r
-               g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (size_mm_callback),\r
-                                                                (gpointer)this);\r
-               gtk_tooltips_set_tip (pTooltips, w, "Set the size of the image using the mapcoordsmins and mapcoordsmaxs keys of the worldspawn entity", NULL);\r
-               gtk_widget_show (w);\r
-       }\r
-\r
-       gtk_widget_show (hbox);\r
-       gtk_widget_show (frame);\r
-\r
-  gtk_widget_show ( m_pWidget );\r
-}\r
-\r
-void CBackgroundDialogPage::Append(GtkWidget *notebook)\r
-{\r
-       gtk_notebook_append_page( GTK_NOTEBOOK(notebook), m_pWidget, m_pTabLabel);\r
-}\r
-\r
-// dialog global callbacks\r
-/*\r
-static gint expose_callback( GtkWidget *widget, gpointer data )\r
-{\r
-       return FALSE;\r
-}\r
-*/\r
-\r
-static void response_callback( GtkWidget *widget, gint response, gpointer data )\r
-{\r
-       if( response == GTK_RESPONSE_CLOSE )\r
-               gtk_widget_hide( pDialogWnd );\r
-}\r
-\r
-static gint close_callback( GtkWidget *widget, gpointer data )\r
-{\r
-       gtk_widget_hide( pDialogWnd );\r
-       return TRUE;\r
-}\r
-\r
-void InitBackgroundDialog()\r
-{\r
-       CBackgroundDialogPage *pPage;\r
-\r
-       pDialogWnd = gtk_dialog_new_with_buttons ("Background Images",\r
-                              GTK_WINDOW(g_pMainWidget),\r
-                              (GtkDialogFlags)(GTK_DIALOG_DESTROY_WITH_PARENT),\r
-        // TODO dialog with no buttons\r
-        //                                                                               GTK_STOCK_CLOSE,\r
-        //                                                                               GTK_RESPONSE_CLOSE,\r
-                              NULL);\r
-       gtk_signal_connect( GTK_OBJECT (pDialogWnd), "delete_event",\r
-                                    GTK_SIGNAL_FUNC( close_callback ), NULL );\r
-       gtk_signal_connect( GTK_OBJECT (pDialogWnd), "response",\r
-                                  GTK_SIGNAL_FUNC( response_callback ), NULL );\r
-//     gtk_signal_connect( GTK_OBJECT (pDialogWnd), "expose_event", GTK_SIGNAL_FUNC( ci_expose ), NULL );\r
-\r
-       pTooltips = gtk_tooltips_new();\r
-\r
-       pNotebook = gtk_notebook_new();\r
-       pPage = new CBackgroundDialogPage(XY);\r
-       pPage->Append(pNotebook);\r
-       pPage = new CBackgroundDialogPage(XZ);\r
-       pPage->Append(pNotebook);\r
-       pPage = new CBackgroundDialogPage(YZ);\r
-       pPage->Append(pNotebook);\r
-\r
-       gtk_box_pack_start (GTK_BOX (GTK_DIALOG(pDialogWnd)->vbox), pNotebook, TRUE, TRUE, 0);\r
-\r
-  gtk_widget_show ( pNotebook );\r
-       \r
-       gtk_widget_realize( pDialogWnd );\r
-}\r
-\r
-void ShowBackgroundDialog()\r
-{\r
-       gtk_window_present( GTK_WINDOW(pDialogWnd) );\r
-}\r
-\r
-void ShowBackgroundDialogPG(int page)\r
-{\r
-       gtk_notebook_set_current_page(GTK_NOTEBOOK(pNotebook),page);\r
-       ShowBackgroundDialog();\r
-}\r
-\r
+/*
+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();
+}
+
index ce27430..09e9ed7 100644 (file)
-/*\r
-Copyright (C) 2003 Reed Mideke.\r
-\r
-This file is part of GtkRadiant.\r
-\r
-GtkRadiant is free software; you can redistribute it and/or modify\r
-it under the terms of the GNU General Public License as published by\r
-the Free Software Foundation; either version 2 of the License, or\r
-(at your option) any later version.\r
-\r
-GtkRadiant is distributed in the hope that it will be useful,\r
-but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-GNU General Public License for more details.\r
-\r
-You should have received a copy of the GNU General Public License\r
-along with GtkRadiant; if not, write to the Free Software\r
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
-*/\r
-\r
-//\r
-// 2d background Plugin\r
-//\r
-// Code by reyalP aka Reed Mideke\r
-//\r
-// Based on \r
-//\r
-\r
-/*\r
-    Overview\r
-    ========\r
-       This little plugin allows you to display an image in the background of the\r
-       gtkradiant XY window.\r
-\r
-    Version History\r
-    ===============\r
-\r
-    v0.1\r
-      - Initial version.\r
-       v0.2\r
-         - three views, dialog box, toolbar\r
-    v0.25\r
-      - tooltips, follow gtkradiant coding conventions\r
-\r
-    Why ?\r
-    -----\r
-      http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=88\r
-\r
-\r
-    How ?\r
-    -----\r
-     - textures 'n widgets 'n stuff.\r
-*/\r
-\r
-//#include "plugin.h"\r
-//TODO we just poke the objects directly\r
-#include "bkgrnd2d.h"\r
-#include "dialog.h"\r
-\r
-#define CMD_SEP "-" \r
-#define CMD_CONFIG "Configure..."\r
-#define CMD_ABOUT "About..."\r
-// =============================================================================\r
-// Globals\r
-\r
-// function tables\r
-_QERFuncTable_1 g_FuncTable;\r
-_QERQglTable g_QglTable;\r
-_QERFileSystemTable g_FileSystemTable;\r
-_QEREntityTable g_EntityTable;\r
-_QERAppDataTable g_DataTable;\r
-\r
-// for the file load dialog\r
-void *g_pMainWidget;\r
-\r
-// =============================================================================\r
-// plugin implementation\r
-\r
-static const char *PLUGIN_NAME = "2d window background plugin";\r
-\r
-//backwards for some reason\r
-static const char *PLUGIN_COMMANDS = CMD_ABOUT ";" \r
-                                     CMD_SEP ";"\r
-                                                                                        CMD_CONFIG\r
-                                     ;\r
-\r
-static const char *PLUGIN_ABOUT = "2d window background v0.25\n\n"\r
-                                  "By reyalP (hellsownpuppy@yahoo.com)";\r
-\r
-\r
-\r
-\r
-void DoBkgrndToggleXY();\r
-void DoBkgrndToggleXZ();\r
-void DoBkgrndToggleYZ();\r
-\r
-#define NUM_TOOLBAR_BUTTONS 4\r
-struct toolbar_button_info_s\r
-{\r
-       char *image;\r
-       char *text;\r
-       char *tip;\r
-       void (*func)();\r
-       IToolbarButton::EType type;\r
-};\r
-\r
-struct toolbar_button_info_s toolbar_buttons[NUM_TOOLBAR_BUTTONS] = \r
-{\r
-       {\r
-               "bkgrnd2d_xy_toggle.bmp",\r
-               "xy background",\r
-    "Toggle xy background image",\r
-               DoBkgrndToggleXY,\r
-               IToolbarButton::eToggleButton\r
-       },\r
-       {\r
-               "bkgrnd2d_xz_toggle.bmp",\r
-               "xz background",\r
-    "Toggle xz background image",\r
-               DoBkgrndToggleXZ,\r
-               IToolbarButton::eToggleButton\r
-       },\r
-       {\r
-               "bkgrnd2d_yz_toggle.bmp",\r
-               "yz background",\r
-    "Toggle yz background image",\r
-               DoBkgrndToggleYZ,\r
-               IToolbarButton::eToggleButton\r
-       },\r
-       {\r
-               "bkgrnd2d_conf.bmp",\r
-               "Configure",\r
-    "Configure background images",\r
-               ShowBackgroundDialog,\r
-               IToolbarButton::eButton\r
-       },\r
-};\r
-\r
-class Bkgrnd2dButton : public IToolbarButton\r
-{\r
-public:\r
-  const toolbar_button_info_s *bi;\r
-  virtual const char* getImage() const\r
-  {\r
-    return bi->image;\r
-  }\r
-  virtual const char* getText() const\r
-  {\r
-    return bi->text;\r
-  }\r
-  virtual const char* getTooltip() const\r
-  {\r
-    return bi->tip;\r
-  }\r
-  virtual void activate() const\r
-  {\r
-    bi->func();\r
-    return ;\r
-  }\r
-  virtual EType getType() const\r
-  {\r
-    return bi->type;\r
-  }\r
-};\r
-\r
-Bkgrnd2dButton g_bkgrnd2dbuttons[NUM_TOOLBAR_BUTTONS];\r
-\r
-unsigned int ToolbarButtonCount()\r
-{\r
-  return NUM_TOOLBAR_BUTTONS;\r
-}\r
-\r
-const IToolbarButton* GetToolbarButton(unsigned int index)\r
-{\r
-  g_bkgrnd2dbuttons[index].bi = &toolbar_buttons[index];\r
-  return &g_bkgrnd2dbuttons[index];\r
-}\r
-\r
-extern "C" const char* QERPlug_Init (void *hApp, void* pMainWidget)\r
-{\r
-  g_pMainWidget = pMainWidget;\r
-\r
-  InitBackgroundDialog();\r
-  render.Register();\r
-\r
-//TODO is it right ? is it wrong ? it works\r
-//TODO figure out supported image types\r
-  GetFileTypeRegistry()->addType(FILETYPE_KEY, filetype_t("all files", "*.*"));\r
-  GetFileTypeRegistry()->addType(FILETYPE_KEY, filetype_t("jpeg files", "*.jpg"));\r
-  GetFileTypeRegistry()->addType(FILETYPE_KEY, filetype_t("targa files", "*.tga"));\r
-  return (char *) PLUGIN_NAME;\r
-}\r
-\r
-extern "C" const char* QERPlug_GetName ()\r
-{\r
-  return (char *) PLUGIN_NAME;\r
-}\r
-\r
-extern "C" const char* QERPlug_GetCommandList ()\r
-{\r
-  return (char *) PLUGIN_COMMANDS;\r
-}\r
-\r
-extern "C" void QERPlug_Dispatch (const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush)\r
-{\r
-  Sys_Printf (MSG_PREFIX "Command \"%s\"\n",p); \r
-  if(!strcmp(p, CMD_ABOUT)) {\r
-       g_FuncTable.m_pfnMessageBox(NULL, PLUGIN_ABOUT, "About", MB_OK, NULL);\r
-  } \r
-  else if(!strcmp(p,CMD_CONFIG)) {\r
-       ShowBackgroundDialog();\r
-  }\r
-}\r
-\r
-//TODO these three suck\r
-void DoBkgrndToggleXY()\r
-{\r
-  Sys_Printf (MSG_PREFIX "DoBkgrndToggleXY\n"); \r
-  // always toggle, since the buttons do\r
-  backgroundXY.m_bActive = (backgroundXY.m_bActive) ? false:true;\r
-  // if we don't have image or extents, and we activated,\r
-  // bring up the dialog with the corresponding page\r
-  // would be better to hide or grey out button, but we can't\r
-  if(backgroundXY.m_bActive && !backgroundXY.Valid())\r
-         ShowBackgroundDialogPG(0);\r
-  else\r
-         g_FuncTable.m_pfnSysUpdateWindows(W_XY);\r
-}\r
-\r
-void DoBkgrndToggleXZ()\r
-{\r
-  Sys_Printf (MSG_PREFIX "DoBkgrndToggleXZ\n"); \r
-  backgroundXZ.m_bActive = (backgroundXZ.m_bActive) ? false:true;\r
-  if(backgroundXZ.m_bActive && !backgroundXZ.Valid())\r
-         ShowBackgroundDialogPG(1);\r
-  else\r
-         g_FuncTable.m_pfnSysUpdateWindows(W_XY);\r
-}\r
-\r
-void DoBkgrndToggleYZ()\r
-{\r
-  Sys_Printf (MSG_PREFIX "DoBkgrndToggleYZ\n"); \r
-  backgroundYZ.m_bActive = (backgroundYZ.m_bActive) ? false:true;\r
-  if(backgroundYZ.m_bActive && !backgroundYZ.Valid())\r
-         ShowBackgroundDialogPG(2);\r
-  else\r
-         g_FuncTable.m_pfnSysUpdateWindows(W_XY);\r
-}\r
-\r
-// =============================================================================\r
-// SYNAPSE\r
-\r
-CSynapseServer* g_pSynapseServer = NULL;\r
-CSynapseClientBkgrnd2d g_SynapseClient;\r
-    \r
-extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const char *version, CSynapseServer *pServer)\r
-{\r
-  if (strcmp(version, SYNAPSE_VERSION))\r
-  {\r
-    Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);\r
-    return NULL;\r
-  }\r
-  g_pSynapseServer = pServer;\r
-  g_pSynapseServer->IncRef();\r
-  Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());\r
-\r
-  g_SynapseClient.AddAPI(TOOLBAR_MAJOR, BKGRND2D_MINOR, sizeof(_QERPlugToolbarTable));\r
-  g_SynapseClient.AddAPI(PLUGIN_MAJOR, BKGRND2D_MINOR, sizeof( _QERPluginTable ) );\r
-\r
-  g_SynapseClient.AddAPI( RADIANT_MAJOR, NULL, sizeof( g_FuncTable ), SYN_REQUIRE, &g_FuncTable );\r
-  g_SynapseClient.AddAPI( QGL_MAJOR, NULL, sizeof( g_QglTable ), SYN_REQUIRE, &g_QglTable );\r
-// TODO is this the right way to ask for 'whichever VFS we have loaded' ? Seems to work\r
-// for misc filename functions\r
-  g_SynapseClient.AddAPI( VFS_MAJOR, "*", sizeof( g_FileSystemTable ), SYN_REQUIRE, &g_FileSystemTable );\r
-// get worldspawn\r
-  g_SynapseClient.AddAPI( ENTITY_MAJOR, NULL, sizeof( g_EntityTable ), SYN_REQUIRE, &g_EntityTable );\r
-// selected brushes\r
-  g_SynapseClient.AddAPI( DATA_MAJOR, NULL, sizeof( g_DataTable ), SYN_REQUIRE, &g_DataTable );\r
-\r
-  return &g_SynapseClient;\r
-}\r
-\r
-bool CSynapseClientBkgrnd2d::RequestAPI(APIDescriptor_t *pAPI)\r
-{\r
-  if (!strcmp(pAPI->major_name, PLUGIN_MAJOR))\r
-  {\r
-    _QERPluginTable* pTable= static_cast<_QERPluginTable*>(pAPI->mpTable);\r
-\r
-    pTable->m_pfnQERPlug_Init = QERPlug_Init;\r
-    pTable->m_pfnQERPlug_GetName = QERPlug_GetName;\r
-    pTable->m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;\r
-    pTable->m_pfnQERPlug_Dispatch = QERPlug_Dispatch;\r
-    return true;\r
-  }\r
-  if (!strcmp(pAPI->major_name, TOOLBAR_MAJOR))\r
-  {\r
-    _QERPlugToolbarTable* pTable= static_cast<_QERPlugToolbarTable*>(pAPI->mpTable);\r
-\r
-    pTable->m_pfnToolbarButtonCount = &ToolbarButtonCount;\r
-    pTable->m_pfnGetToolbarButton = &GetToolbarButton;\r
-    return true;\r
-  }\r
-\r
-  Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());\r
-  return false;\r
-}\r
-\r
-#include "version.h"\r
-\r
-const char* CSynapseClientBkgrnd2d::GetInfo()\r
-{\r
-  return "2d Background plugin built " __DATE__ " " RADIANT_VERSION;\r
-}\r
-\r
-const char* CSynapseClientBkgrnd2d::GetName()\r
-{\r
-  return "bkgrnd2d";\r
-}\r
-\r
+/*
+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";
+}
+
index d9f62e1..3a7c7ce 100644 (file)
@@ -1,23 +1,23 @@
-/*\r
-Copyright (C) 2001-2006, William Joseph.\r
-All Rights Reserved.\r
-\r
-This file is part of GtkRadiant.\r
-\r
-GtkRadiant is free software; you can redistribute it and/or modify\r
-it under the terms of the GNU General Public License as published by\r
-the Free Software Foundation; either version 2 of the License, or\r
-(at your option) any later version.\r
-\r
-GtkRadiant is distributed in the hope that it will be useful,\r
-but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-GNU General Public License for more details.\r
-\r
-You should have received a copy of the GNU General Public License\r
-along with GtkRadiant; if not, write to the Free Software\r
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
-*/\r
-\r
-#include "stack.h"\r
-\r
+/*
+Copyright (C) 2001-2006, William Joseph.
+All Rights Reserved.
+
+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
+*/
+
+#include "stack.h"
+