123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- #include "api__vis_milk2.h"
- #include <windows.h>
- #include "vis.h"
- #include "plugin.h"
- #include "defines.h"
- #include "resource.h"
- #include "utility.h"
- CPlugin g_plugin;
- _locale_t g_use_C_locale = 0;
- char keyMappings[8];
- bool g_bFullyExited = true;
- api_service *WASABI_API_SVC = 0;
- api_language *WASABI_API_LNG = 0;
- api_application *WASABI_API_APP = 0;
- api_syscb *WASABI_API_SYSCB = 0;
- HINSTANCE WASABI_API_LNG_HINST = 0, WASABI_API_ORIG_HINST = 0;
- void config(struct winampVisModule *this_mod);
- int init(struct winampVisModule *this_mod);
- int render1(struct winampVisModule *this_mod);
- void quit(struct winampVisModule *this_mod);
- winampVisModule mod1 =
- {
- MODULEDESC,
- NULL,
- NULL,
- 0,
- 0,
- 0,
-
- 10,
-
-
-
-
- 0,
- 2,
- { 0, },
- { 0, },
- config,
- init,
- render1,
- quit
- };
- winampVisModule *getModule(int which)
- {
- switch (which)
- {
- case 0: return &mod1;
-
-
- default: return NULL;
- }
- }
- winampVisHeader hdr = { VIS_HDRVER, DLLDESC, getModule };
- static HINSTANCE GetMyInstance()
- {
- MEMORY_BASIC_INFORMATION mbi = {0};
- if(VirtualQuery(GetMyInstance, &mbi, sizeof(mbi)))
- return (HINSTANCE)mbi.AllocationBase;
- return NULL;
- }
- #ifdef __cplusplus
- extern "C" {
- #endif
- __declspec( dllexport ) winampVisHeader *winampVisGetHeader(HWND hwndParent)
- {
- if(!WASABI_API_LNG_HINST)
- {
-
- WASABI_API_SVC = (api_service*)SendMessage(hwndParent, WM_WA_IPC, 0, IPC_GET_API_SERVICE);
- if (WASABI_API_SVC == (api_service*)1) WASABI_API_SVC = NULL;
- waServiceFactory *sf = WASABI_API_SVC->service_getServiceByGuid(languageApiGUID);
- if (sf) WASABI_API_LNG = reinterpret_cast<api_language*>(sf->getInterface());
- sf = WASABI_API_SVC->service_getServiceByGuid(applicationApiServiceGuid);
- if (sf) WASABI_API_APP = reinterpret_cast<api_application*>(sf->getInterface());
- sf = WASABI_API_SVC->service_getServiceByGuid(syscbApiServiceGuid);
- if (sf) WASABI_API_SYSCB = reinterpret_cast<api_syscb*>(sf->getInterface());
-
- WASABI_API_START_LANG(GetMyInstance(),VisMilkdropLangGUID);
-
- WASABI_API_LNGSTRING_BUF(IDS_KEY_MAPPINGS, keyMappings, 8);
-
-
- g_use_C_locale = WASABI_API_LNG->Get_C_NumericLocale();
- }
- return &hdr;
- }
- #ifdef __cplusplus
- }
- #endif
-
- bool WaitUntilPluginFinished(HWND hWndWinamp)
- {
- int slept = 0;
- while (!g_bFullyExited && slept < 1000)
- {
- Sleep(50);
- slept += 50;
- }
- if (!g_bFullyExited)
- {
- wchar_t title[64];
- MessageBoxW(hWndWinamp, WASABI_API_LNGSTRINGW(IDS_ERROR_THE_PLUGIN_IS_ALREADY_RUNNING),
- WASABI_API_LNGSTRINGW_BUF(IDS_MILKDROP_ERROR, title, 64),
- MB_OK|MB_SETFOREGROUND|MB_TOPMOST);
- return false;
- }
- return true;
- }
- HWND GetDialogBoxParent(HWND winamp)
- {
- HWND parent = (HWND)SendMessage(winamp, WM_WA_IPC, 0, IPC_GETDIALOGBOXPARENT);
- if (!parent || parent == (HWND)1)
- return winamp;
- return parent;
- }
- void config(struct winampVisModule *this_mod)
- {
- if (!g_bFullyExited)
- {
- g_plugin.OnAltK();
- return;
- }
- g_bFullyExited = false;
- g_plugin.PluginPreInitialize(this_mod->hwndParent, this_mod->hDllInstance);
- WASABI_API_DIALOGBOXPARAMW(IDD_CONFIG, GetDialogBoxParent(this_mod->hwndParent), g_plugin.ConfigDialogProc, (LPARAM)&g_plugin);
- g_bFullyExited = true;
- }
- int (*warand)(void) = 0;
- int fallback_rand_fn(void) {
- return rand();
- }
- int init(struct winampVisModule *this_mod)
- {
- DWORD version = GetWinampVersion(mod1.hwndParent);
- if (!warand)
- {
- warand = (int (*)(void))SendMessage(this_mod->hwndParent, WM_WA_IPC, 0, IPC_GET_RANDFUNC);
- if ((size_t)warand <= 1)
- {
- warand = fallback_rand_fn;
- }
- }
-
- if (!WaitUntilPluginFinished(this_mod->hwndParent))
- {
- return 1;
- }
- if (GetWinampVersion(mod1.hwndParent) < 0x4000)
- {
-
- LRESULT ret = SendMessage(this_mod->hwndParent, WM_USER, 0, 104);
-
- if (ret != 1)
- {
- wchar_t title[64];
- MessageBoxW(this_mod->hwndParent, WASABI_API_LNGSTRINGW(IDS_THIS_PLUGIN_NEEDS_MUSIC_TO_RUN),
- WASABI_API_LNGSTRINGW_BUF(IDS_NO_MUSIC_PLAYING, title, 64),
- MB_OK|MB_SETFOREGROUND|MB_TOPMOST|MB_TASKMODAL );
- return 1;
- }
- }
- g_bFullyExited = false;
- if (!g_plugin.PluginPreInitialize(this_mod->hwndParent, this_mod->hDllInstance))
- {
- g_plugin.PluginQuit();
- g_bFullyExited = true;
- return 1;
- }
- if (!g_plugin.PluginInitialize())
- {
- g_plugin.PluginQuit();
- g_bFullyExited = true;
- return 1;
- }
- return 0;
- }
- int render1(struct winampVisModule *this_mod)
- {
- if (g_plugin.PluginRender(this_mod->waveformData[0], this_mod->waveformData[1]))
- return 0;
- else
- return 1;
- }
- void quit(struct winampVisModule *this_mod)
- {
- g_plugin.PluginQuit();
- g_bFullyExited = true;
- }
|