ctfToolz-GTK.cpp 2.6 KB

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