fixed eol-style

git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@22 8a3a26a2-13c4-0310-b231-cf6edde360e5
This commit is contained in:
spog 2006-02-21 21:09:05 +00:00
parent d549cd09c5
commit 29ac8a44c6
4 changed files with 1024 additions and 1024 deletions

View file

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

View file

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

View file

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

View file

@ -1,23 +1,23 @@
/* /*
Copyright (C) 2001-2006, William Joseph. Copyright (C) 2001-2006, William Joseph.
All Rights Reserved. All Rights Reserved.
This file is part of GtkRadiant. This file is part of GtkRadiant.
GtkRadiant is free software; you can redistribute it and/or modify GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
GtkRadiant is distributed in the hope that it will be useful, GtkRadiant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "stack.h" #include "stack.h"