]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
* added filter api to create new filters from within plugins
authormattn <mattn>
Sun, 16 Mar 2008 09:42:56 +0000 (09:42 +0000)
committermattn <mattn>
Sun, 16 Mar 2008 09:42:56 +0000 (09:42 +0000)
* TTimo, please have a look at the mainframe.cpp part

git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/branches/ZeroRadiant@208 8a3a26a2-13c4-0310-b231-cf6edde360e5

plugins/sample/plugin.cpp
radiant/filters.cpp
radiant/filters.h
radiant/mainframe.cpp
radiant/pluginmanager.cpp

index e80beae47e1fb908a0a5661ba8be5964ad1122dd..e59712173ce34bdde37052939d860f6ac0d8eee2 100644 (file)
@@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include "plugin.h"
 
-#define CMD_SEP "-"
+#define CMD_SEP "-" 
 #define CMD_ABOUT "About..."
 // =============================================================================
 // Globals
@@ -60,12 +60,12 @@ typedef struct toolbar_button_info_s
        IToolbarButton::EType type;
 } toolbar_button_info_t;
 
-static const toolbar_button_info_t toolbar_buttons[NUM_TOOLBAR_BUTTONS] =
+static const toolbar_button_info_t toolbar_buttons[NUM_TOOLBAR_BUTTONS] = 
 {
        {
                "sample.bmp",
                "Sample",
-       "Sample image",
+               "Sample image",
                DoSample,
                IToolbarButton::eToggleButton
        },
@@ -146,7 +146,7 @@ CSynapseClientSample g_SynapseClient;
 #if __GNUC__ >= 4
 #pragma GCC visibility push(default)
 #endif
-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 __GNUC__ >= 4
 #pragma GCC visibility pop
@@ -161,7 +161,7 @@ extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const
 
        g_SynapseClient.AddAPI(TOOLBAR_MAJOR, SAMPLE_MINOR, sizeof(_QERPlugToolbarTable));
        g_SynapseClient.AddAPI(PLUGIN_MAJOR, SAMPLE_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);
        g_SynapseClient.AddAPI(VFS_MAJOR, "*", sizeof(g_FileSystemTable), SYN_REQUIRE, &g_FileSystemTable);
@@ -177,7 +177,7 @@ bool CSynapseClientSample::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;
@@ -185,12 +185,12 @@ bool CSynapseClientSample::RequestAPI (APIDescriptor_t *pAPI)
                return true;
        } else 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;
 }
index f4dd1ba3c58939e1d246fab48d393e479b85e512..4931d4d3974e1b2538b59bd0a3187137c214d93e 100644 (file)
@@ -30,6 +30,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include "stdafx.h"
 
+// type 1 = texture filter (name)
+// type 3 = entity filter (name)
+// type 2 = QER_* shader flags
+// type 4 = entity classes
 bfilter_t *FilterAdd(bfilter_t *pFilter, int type, int bmask, char *str, int exclude)
 {
        bfilter_t *pNew = new bfilter_t;
@@ -44,6 +48,21 @@ bfilter_t *FilterAdd(bfilter_t *pFilter, int type, int bmask, char *str, int exc
        return pNew;
 }
 
+bfilter_t *FilterCreate (int type, int bmask, char *str, int exclude)
+{
+       g_qeglobals.d_savedinfo.filters = FilterAdd(g_qeglobals.d_savedinfo.filters, type, bmask, str, exclude);
+       Syn_Printf("Added filter %s (type: %i, bmask: %i, exclude: %i)\n", str, type, bmask, exclude);
+       return g_qeglobals.d_savedinfo.filters;
+}
+
+extern void PerformFiltering();
+
+void FiltersActivate (void)
+{
+       PerformFiltering();
+       Sys_UpdateWindows(W_XY|W_CAMERA);
+}
+
   // removes the filter list at *pFilter, returns NULL pointer
 bfilter_t *FilterListDelete(bfilter_t *pFilter)
 {
index b09d36f35cc983ecb4d94f0eb0a877cdd25cfc5b..05776f55995de56b61b8993b122c3995061852a5 100644 (file)
@@ -22,6 +22,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #ifndef _FILTERS_H_
 #define _FILTERS_H_
 
+void FiltersActivate(void);
+bfilter_t *FilterCreate(int type, int bmask, char *str, int exclude);
 bfilter_t *FilterAdd(bfilter_t *pFilter, int type, int bmask, char *str, int exclude);
 bfilter_t *FilterListDelete(bfilter_t *pFilter);
 bfilter_t *FilterUpdate(bfilter_t *pFilter);
index aa6ef5e7fe714ed0bad12acc53f176c89535fd80..6c2bd2b9bcdf987fb9c4b5a747e9b7d07e534fe0 100644 (file)
@@ -7474,10 +7474,14 @@ void PerformFiltering ()
 {
   brush_t *brush;
 
+  // mattn - this should be removed - otherwise the filters from the 
+  // plugins are wiped away with each update
+#if 1
   // spog - deletes old filters list and creates new one when
   // g_qeglobals.d_savedinfo.exclude is updated
   g_qeglobals.d_savedinfo.filters = FilterListDelete(g_qeglobals.d_savedinfo.filters);
   g_qeglobals.d_savedinfo.filters = FilterUpdate(g_qeglobals.d_savedinfo.filters);
+#endif
 
   for ( brush = active_brushes.next; brush != &active_brushes; brush = brush->next )
     brush->bFiltered = FilterBrush( brush );
index 609e80655cb6f8db58950fc3471d92669fbc1c04..021531ac1c7319068a90ef64d5b7902b40270e62 100644 (file)
@@ -43,6 +43,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include "pluginmanager.h"
 #include "plugin.h"
 #include "missing.h"
+#include "filters.h"
 
 #include "version.h"
 
@@ -2228,6 +2229,8 @@ bool CSynapseClientRadiant::RequestAPI(APIDescriptor_t *pAPI)
     pTable->m_pfnGetFileTypeRegistry = &GetFileTypeRegistry;
     pTable->m_pfnReadProjectKey = &QERApp_ReadProjectKey;
     pTable->m_pfnGetMapName = &QERApp_GetMapName;
+    pTable->m_pfnFilterAdd = &FilterCreate;
+    pTable->m_pfnFiltersActivate = &FiltersActivate;
 
     return true;
   }