From: mattn Date: Sun, 16 Mar 2008 09:53:49 +0000 (+0000) Subject: * updated ufoai plugin X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=aba7cc31e98e18de5833b2f64a192f4d79428a73;p=xonotic%2Fnetradiant.git * updated ufoai plugin * converted toolbar icons to indexed bitmaps - none indexed bitmaps are not supported git-svn-id: https://zerowing.idsoftware.com/svn/radiant/GtkRadiant/branches/ZeroRadiant@211 8a3a26a2-13c4-0310-b231-cf6edde360e5 --- diff --git a/contrib/ufoai/bitmaps/ufoai_actorclip.bmp b/contrib/ufoai/bitmaps/ufoai_actorclip.bmp index 43bdf933..4a2887c6 100644 Binary files a/contrib/ufoai/bitmaps/ufoai_actorclip.bmp and b/contrib/ufoai/bitmaps/ufoai_actorclip.bmp differ diff --git a/contrib/ufoai/bitmaps/ufoai_nodraw.bmp b/contrib/ufoai/bitmaps/ufoai_nodraw.bmp index b9948562..3eaa529c 100644 Binary files a/contrib/ufoai/bitmaps/ufoai_nodraw.bmp and b/contrib/ufoai/bitmaps/ufoai_nodraw.bmp differ diff --git a/contrib/ufoai/bitmaps/ufoai_stepon.bmp b/contrib/ufoai/bitmaps/ufoai_stepon.bmp index 828449ef..b73896fb 100644 Binary files a/contrib/ufoai/bitmaps/ufoai_stepon.bmp and b/contrib/ufoai/bitmaps/ufoai_stepon.bmp differ diff --git a/contrib/ufoai/bitmaps/ufoai_weaponclip.bmp b/contrib/ufoai/bitmaps/ufoai_weaponclip.bmp index fe6b3485..799468ba 100644 Binary files a/contrib/ufoai/bitmaps/ufoai_weaponclip.bmp and b/contrib/ufoai/bitmaps/ufoai_weaponclip.bmp differ diff --git a/contrib/ufoai/plugin.cpp b/contrib/ufoai/plugin.cpp index 83562902..b2b9409e 100644 --- a/contrib/ufoai/plugin.cpp +++ b/contrib/ufoai/plugin.cpp @@ -47,7 +47,7 @@ void *g_pMainWidget; static const char *PLUGIN_COMMANDS = CMD_ABOUT ";" CMD_SEP; static const char *PLUGIN_ABOUT = "UFO: Alien Invasion plugin " PLUGIN_VERSION "\nby Martin Gerhardy"; -#define NUM_TOOLBAR_BUTTONS 12 +#define NUM_TOOLBAR_BUTTONS FILTER_MAX typedef struct toolbar_button_info_s { char *image; @@ -59,6 +59,34 @@ typedef struct toolbar_button_info_s static const toolbar_button_info_t toolbar_buttons[NUM_TOOLBAR_BUTTONS] = { + { + "ufoai_actorclip.bmp", + "Filter actorclip", + "Actorclip", + DoActorClipFiltering, + IToolbarButton::eToggleButton + }, + { + "ufoai_weaponclip.bmp", + "Filter weaponclip", + "Weaponclip", + DoWeaponClipFiltering, + IToolbarButton::eToggleButton + }, + { + "ufoai_nodraw.bmp", + "Filter nodraw", + "NoDraw", + DoNoDrawFiltering, + IToolbarButton::eToggleButton + }, + { + "ufoai_stepon.bmp", + "Filter stepon", + "Stepon", + DoSteponFiltering, + IToolbarButton::eToggleButton + }, { "ufoai_level1.bmp", "Filter level1", @@ -115,34 +143,6 @@ static const toolbar_button_info_t toolbar_buttons[NUM_TOOLBAR_BUTTONS] = DoLevel8Filtering, IToolbarButton::eToggleButton }, - { - "ufoai_actorclip.bmp", - "Filter actorclip", - "Actorclip", - DoActorClipFiltering, - IToolbarButton::eToggleButton - }, - { - "ufoai_stepon.bmp", - "Filter stepon", - "Stepon", - DoSteponFiltering, - IToolbarButton::eToggleButton - }, - { - "ufoai_weaponclip.bmp", - "Filter weaponclip", - "Weaponclip", - DoWeaponClipFiltering, - IToolbarButton::eToggleButton - }, - { - "ufoai_nodraw.bmp", - "Filter nodraw", - "NoDraw", - DoNoDrawFiltering, - IToolbarButton::eToggleButton - }, }; class UFOAIButton : public IToolbarButton diff --git a/contrib/ufoai/ufoai_filters.cpp b/contrib/ufoai/ufoai_filters.cpp index 3cce5893..ed155b8f 100644 --- a/contrib/ufoai/ufoai_filters.cpp +++ b/contrib/ufoai/ufoai_filters.cpp @@ -1,47 +1,48 @@ #include "plugin.h" +#include "ufoai_filters.h" #include "ifilters.h" #define FilterAdd g_FuncTable.m_pfnFilterAdd - -enum FILTERS { - FILTER_ACTORCLIP, - FILTER_WEAPONCLIP, - FILTER_NODRAW, - FILTER_STEPON, - FILTER_LEVEL1, - FILTER_LEVEL2, - FILTER_LEVEL3, - FILTER_LEVEL4, - FILTER_LEVEL5, - FILTER_LEVEL6, - FILTER_LEVEL7, - FILTER_LEVEL8, - - FILTER_MAX -}; +#define FiltersActivate g_FuncTable.m_pfnFiltersActivate static bfilter_t* filters[FILTER_MAX]; void UFOAIFilterInit (void) { - filters[FILTER_LEVEL1] = FilterAdd(1, 0, "level1", (0x10 << 0)); - filters[FILTER_LEVEL2] = FilterAdd(1, 0, "level2", (0x10 << 1)); - filters[FILTER_LEVEL3] = FilterAdd(1, 0, "level3", (0x10 << 2)); - filters[FILTER_LEVEL4] = FilterAdd(1, 0, "level4", (0x10 << 3)); - filters[FILTER_LEVEL5] = FilterAdd(1, 0, "level5", (0x10 << 4)); - filters[FILTER_LEVEL6] = FilterAdd(1, 0, "level6", (0x10 << 5)); - filters[FILTER_LEVEL7] = FilterAdd(1, 0, "level7", (0x10 << 6)); - filters[FILTER_LEVEL8] = FilterAdd(1, 0, "level8", (0x10 << 7)); + filters[FILTER_ACTORCLIP] = FilterAdd(2, 0, "actorclip", UFOAI_CONTENTS_ACTORCLIP); + filters[FILTER_WEAPONCLIP] = FilterAdd(2, 0, "weaponclip", UFOAI_CONTENTS_WEAPONCLIP); + filters[FILTER_NODRAW] = FilterAdd(2, 0, "nodraw", UFOAI_SURF_NODRAW); + filters[FILTER_STEPON] = FilterAdd(2, 0, "stepon", UFOAI_CONTENTS_STEPON); + + filters[FILTER_LEVEL1] = FilterAdd(2, 0, "level1", UFOAI_CONTENTS_LEVEL_1); + filters[FILTER_LEVEL2] = FilterAdd(2, 0, "level2", UFOAI_CONTENTS_LEVEL_2); + filters[FILTER_LEVEL3] = FilterAdd(2, 0, "level3", UFOAI_CONTENTS_LEVEL_3); + filters[FILTER_LEVEL4] = FilterAdd(2, 0, "level4", UFOAI_CONTENTS_LEVEL_4); + filters[FILTER_LEVEL5] = FilterAdd(2, 0, "level5", UFOAI_CONTENTS_LEVEL_5); + filters[FILTER_LEVEL6] = FilterAdd(2, 0, "level6", UFOAI_CONTENTS_LEVEL_6); + filters[FILTER_LEVEL7] = FilterAdd(2, 0, "level7", UFOAI_CONTENTS_LEVEL_7); + filters[FILTER_LEVEL8] = FilterAdd(2, 0, "level8", UFOAI_CONTENTS_LEVEL_8); + + Sys_Printf("UFO:AI Filters initialized\n"); } void PerformFiltering (int type) { - switch (type) { - default: - Sys_Printf("TODO: Implement filters"); - break; + if (!filters[type]) { + Sys_Printf("filters are not yet initialized\n"); + return; + } + + if (filters[type]->active) { + filters[type]->active = false; + Sys_Printf("filter %i deactivated\n", type); + } else { + filters[type]->active = true; + Sys_Printf("filter %i activated\n", type); } + + FiltersActivate(); } void DoSteponFiltering(void) diff --git a/contrib/ufoai/ufoai_filters.h b/contrib/ufoai/ufoai_filters.h index 847bd3fb..c9e87237 100644 --- a/contrib/ufoai/ufoai_filters.h +++ b/contrib/ufoai/ufoai_filters.h @@ -1,4 +1,37 @@ +enum FILTERS { + FILTER_ACTORCLIP, + FILTER_WEAPONCLIP, + FILTER_NODRAW, + FILTER_STEPON, + FILTER_LEVEL1, + FILTER_LEVEL2, + FILTER_LEVEL3, + FILTER_LEVEL4, + FILTER_LEVEL5, + FILTER_LEVEL6, + FILTER_LEVEL7, + FILTER_LEVEL8, + + FILTER_MAX +}; + +#define UFOAI_CONTENTS_LEVEL_1 0x0100 +#define UFOAI_CONTENTS_LEVEL_2 0x0200 +#define UFOAI_CONTENTS_LEVEL_3 0x0400 +#define UFOAI_CONTENTS_LEVEL_4 0x0800 +#define UFOAI_CONTENTS_LEVEL_5 0x1000 +#define UFOAI_CONTENTS_LEVEL_6 0x2000 +#define UFOAI_CONTENTS_LEVEL_7 0x4000 +#define UFOAI_CONTENTS_LEVEL_8 0x8000 + +#define UFOAI_CONTENTS_ACTORCLIP 0x00010000 +#define UFOAI_CONTENTS_WEAPONCLIP 0x02000000 +#define UFOAI_CONTENTS_STEPON 0x40000000 + +#define UFOAI_SURF_NODRAW 0x00000080 + + void DoSteponFiltering(void); void DoWeaponClipFiltering(void); void DoActorClipFiltering(void);