123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294 |
- #include <windows.h>
- #include "resource.h"
- #include "avs_ape.h"
- #define MOD_NAME "Tutorials / BOX v1.0"
- #define UNIQUEIDSTRING "Nullsoft Tut0: BOX"
- APEinfo *g_extinfo;
- extern "C"
- {
- void __declspec(dllexport) _AVS_APE_SetExtInfo(HINSTANCE hDllInstance, APEinfo *ptr)
- {
- g_extinfo = ptr;
- }
- }
- class C_THISCLASS : public C_RBASE
- {
- protected:
- public:
- C_THISCLASS();
- virtual ~C_THISCLASS();
- virtual int render(char visdata[2][2][576], int isBeat, int *framebuffer, int *fbout, int w, int h);
-
- virtual HWND conf(HINSTANCE hInstance, HWND hwndParent);
- virtual char *get_desc();
- virtual void load_config(unsigned char *data, int len);
- virtual int save_config(unsigned char *data);
- int enabled;
- int color;
- };
- static C_THISCLASS *g_ConfigThis;
- static HINSTANCE g_hDllInstance;
- static BOOL CALLBACK g_DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
- {
- switch (uMsg)
- {
- case WM_INITDIALOG:
- if (g_ConfigThis->enabled)
- {
- CheckDlgButton(hwndDlg,IDC_CHECK1,BST_CHECKED);
- }
- return 1;
- case WM_DRAWITEM:
-
- DRAWITEMSTRUCT *di;
-
- di=(DRAWITEMSTRUCT *)lParam;
- if (di->CtlID == IDC_DEFCOL)
- {
- int w;
- int color;
- w=di->rcItem.right-di->rcItem.left;
- color=g_ConfigThis->color;
- color = ((color>>16)&0xff)|(color&0xff00)|((color<<16)&0xff0000);
-
-
- HBRUSH hBrush,hOldBrush;
- LOGBRUSH lb={BS_SOLID,color,0};
- hBrush = CreateBrushIndirect(&lb);
- hOldBrush=(HBRUSH)SelectObject(di->hDC,hBrush);
- Rectangle(di->hDC,di->rcItem.left,di->rcItem.top,di->rcItem.right,di->rcItem.bottom);
- SelectObject(di->hDC,hOldBrush);
- DeleteObject(hBrush);
-
- }
- return 0;
- case WM_COMMAND:
-
- if (LOWORD(wParam) == IDC_CHECK1)
- {
- g_ConfigThis->enabled= (IsDlgButtonChecked(hwndDlg,IDC_CHECK1)?1:0);
- }
-
-
- if (LOWORD(wParam) == IDC_DEFCOL)
- {
- static COLORREF custcolors[16];
- int *a;
- CHOOSECOLOR cs;
-
- a=&g_ConfigThis->color;
- cs.lStructSize = sizeof(cs);
- cs.hwndOwner = hwndDlg;
- cs.hInstance = 0;
- cs.rgbResult=((*a>>16)&0xff)|(*a&0xff00)|((*a<<16)&0xff0000);
- cs.lpCustColors = custcolors;
- cs.Flags = CC_RGBINIT|CC_FULLOPEN;
-
- if (ChooseColor(&cs))
- {
- *a = ((cs.rgbResult>>16)&0xff)|(cs.rgbResult&0xff00)|((cs.rgbResult<<16)&0xff0000);
- }
- InvalidateRect(GetDlgItem(hwndDlg,IDC_DEFCOL),NULL,TRUE);
- }
- return 0;
- }
- return 0;
- }
- C_THISCLASS::C_THISCLASS()
- {
-
- color=RGB(255,0,0);
- enabled=1;
- }
- C_THISCLASS::~C_THISCLASS()
- {
- }
- int C_THISCLASS::render(char visdata[2][2][576], int isBeat, int *framebuffer, int *fbout, int w, int h)
- {
- int halfw;
- int halfh;
-
- if (!enabled)
- {
- return 0;
- }
-
- if(isBeat)
- {
-
- halfw=w/2;
- halfh=h/2;
- framebuffer+=(((halfh/2)*w)+ (halfw/2));
-
- for(int j=0;j<halfh;j++)
- {
- for(int i=0;i<halfw;i++)
- {
- framebuffer[i]=color;
- }
- framebuffer+=w;
- }
- }
- return 0;
- }
- HWND C_THISCLASS::conf(HINSTANCE hInstance, HWND hwndParent)
- {
- g_ConfigThis = this;
- return CreateDialog(hInstance,MAKEINTRESOURCE(IDD_CONFIG),hwndParent,g_DlgProc);
- }
- char *C_THISCLASS::get_desc(void)
- {
- return MOD_NAME;
- }
- #define GET_INT() (data[pos]|(data[pos+1]<<8)|(data[pos+2]<<16)|(data[pos+3]<<24))
- void C_THISCLASS::load_config(unsigned char *data, int len)
- {
- int pos=0;
-
- if (len-pos >= 4)
- {
-
- enabled=GET_INT();
- pos+=4;
- }
- if (len-pos >= 4)
- {
-
- color=GET_INT();
- pos+=4;
- }
- }
- #define PUT_INT(y) data[pos]=(y)&255; data[pos+1]=(y>>8)&255; data[pos+2]=(y>>16)&255; data[pos+3]=(y>>24)&255
- int C_THISCLASS::save_config(unsigned char *data)
- {
- int pos=0;
-
- PUT_INT(enabled);
- pos+=4;
-
- PUT_INT(color);
- pos+=4;
- return pos;
- }
- C_RBASE *R_RetrFunc(char *desc)
- {
- if (desc)
- {
- strcpy(desc,MOD_NAME);
- return NULL;
- }
- return (C_RBASE *) new C_THISCLASS();
- }
- extern "C"
- {
- __declspec (dllexport) int _AVS_APE_RetrFunc(HINSTANCE hDllInstance, char **info, int *create)
- {
- g_hDllInstance=hDllInstance;
- *info=UNIQUEIDSTRING;
- *create=(int)(void*)R_RetrFunc;
- return 1;
- }
- };
|