]> git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/bobtoolz/ctfToolz-GTK.cpp
transfer from internal tree r5311 branches/1.4-gpl
[xonotic/netradiant.git] / contrib / bobtoolz / ctfToolz-GTK.cpp
1 /*\r
2 BobToolz plugin for GtkRadiant\r
3 Copyright (C) 2001 Gordon Biggans\r
4 \r
5 This library is free software; you can redistribute it and/or\r
6 modify it under the terms of the GNU Lesser General Public\r
7 License as published by the Free Software Foundation; either\r
8 version 2.1 of the License, or (at your option) any later version.\r
9 \r
10 This library is distributed in the hope that it will be useful,\r
11 but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
13 Lesser General Public License for more details.\r
14 \r
15 You should have received a copy of the GNU Lesser General Public\r
16 License along with this library; if not, write to the Free Software\r
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
18 */\r
19 \r
20 #include "StdAfx.h"\r
21 \r
22 #include "funchandlers.h"\r
23 #include "misc.h"\r
24 \r
25 #include "dialogs/dialogs-gtk.h"\r
26 \r
27 // Radiant function table\r
28 _QERFuncTable_1                 g_FuncTable;\r
29 _QERAppBSPFrontendTable g_BSPTable;                             // for map name\r
30 \r
31 BOOL g_bBSPInitDone                                     = FALSE;\r
32 \r
33 // plugin name\r
34 static const char *PLUGIN_NAME = "ctfToolz";\r
35 \r
36 // commands in the menu\r
37 static const char *PLUGIN_COMMANDS = "About...,Colour Changer...,Swap Light Colours,Change Angles 180,Swap Spawn Points";\r
38 \r
39 // globals\r
40 GtkWidget *g_pRadiantWnd=NULL;\r
41 \r
42 static const char *PLUGIN_ABOUT = "ctfToolz for GtkRadiant\n"\r
43                                   "by djbob\n"\r
44                                                                   "http://www.planetquake.com/toolz\n\n";\r
45 \r
46 extern "C" LPVOID WINAPI QERPlug_GetFuncTable()\r
47 {\r
48   return &g_FuncTable;\r
49 }\r
50 \r
51 extern "C" LPCSTR WINAPI QERPlug_Init(HMODULE hApp, GtkWidget* pMainWidget)\r
52 {\r
53         g_pRadiantWnd = pMainWidget;\r
54         memset(&g_FuncTable, 0, sizeof(_QERFuncTable_1));\r
55         g_FuncTable.m_fVersion = QER_PLUG_VERSION;\r
56         g_FuncTable.m_nSize = sizeof(_QERFuncTable_1);\r
57 \r
58         return "ctfToolz for GTKradiant";\r
59 }\r
60 \r
61 extern "C" LPCSTR WINAPI QERPlug_GetName()\r
62 {\r
63         return (char*)PLUGIN_NAME;\r
64 }\r
65 \r
66 extern "C" LPCSTR WINAPI QERPlug_GetCommandList()\r
67 {\r
68         return (char*)PLUGIN_COMMANDS;\r
69 }\r
70 \r
71 extern "C" void WINAPI QERPlug_Dispatch (LPCSTR p, vec3_t vMin, vec3_t vMax, bool bSingleBrush)\r
72 {\r
73         LoadLists();\r
74 \r
75         if (!g_bBSPInitDone)\r
76         {\r
77                 g_BSPTable.m_nSize = sizeof(_QERAppBSPFrontendTable);\r
78                 if ( g_FuncTable.m_pfnRequestInterface( QERAppBSPFrontendTable_GUID, static_cast<LPVOID>(&g_BSPTable) ) )\r
79                         g_bBSPInitDone = TRUE;\r
80                 else\r
81                 {\r
82                         Sys_ERROR("_QERAppBSPFrontendTable interface request failed\n");\r
83                         return;\r
84                 }\r
85         }\r
86                 \r
87         if(!strcmp(p, "About..."))\r
88                 DoMessageBox(PLUGIN_ABOUT, "About", IDOK);\r
89         else if(!strcmp(p, "Colour Changer..."))\r
90                 DoCTFColourChanger();\r
91         else if(!strcmp(p, "Swap Light Colours"))\r
92                 DoSwapLights();\r
93         else if(!strcmp(p, "Change Angles 180"))\r
94                 DoChangeAngles();\r
95         else if(!strcmp(p, "Swap Spawn Points"))\r
96                 DoSwapSpawns();\r
97 }\r