From 1d4c82315785aa0d61216483bae4a2511d303bea Mon Sep 17 00:00:00 2001 From: mataes2007 Date: Thu, 2 Jun 2011 12:56:17 +0000 Subject: fixed sounds playing fixed random splash cosmetic fix git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@136 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb --- splashscreen/src/bitmap_funcs.cpp | 24 +++---- splashscreen/src/headers.h | 6 ++ splashscreen/src/main.cpp | 31 ++++----- splashscreen/src/options.cpp | 12 ++-- splashscreen/src/splash.cpp | 142 ++++++++++++++++++-------------------- 5 files changed, 107 insertions(+), 108 deletions(-) (limited to 'splashscreen/src') diff --git a/splashscreen/src/bitmap_funcs.cpp b/splashscreen/src/bitmap_funcs.cpp index 20a1427..09ded3a 100644 --- a/splashscreen/src/bitmap_funcs.cpp +++ b/splashscreen/src/bitmap_funcs.cpp @@ -203,7 +203,7 @@ bool MyBitmap::loadFromFile(TCHAR *fn, TCHAR *fnAlpha) if (!png2dibConvertor) { return false; } - + if ((hFile = CreateFile(fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL)) != INVALID_HANDLE_VALUE) if ((hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != NULL) if ((ppMap = (BYTE*)MapViewOfFile( hMap, FILE_MAP_READ, 0, 0, 0 )) != NULL) @@ -214,7 +214,7 @@ bool MyBitmap::loadFromFile(TCHAR *fn, TCHAR *fnAlpha) param.pSource = ppMap; param.cbSourceSize = cbFileSize; param.pResult = &pDib; - + if (png2dibConvertor((char*)param.pSource, param.cbSourceSize, param.pResult)) pDibBits = (BYTE*)(pDib+1); else @@ -303,7 +303,7 @@ bool MyBitmap::loadFromFile(TCHAR *fn, TCHAR *fnAlpha) MyBitmap alpha; if (fnAlpha && alpha.loadFromFile(fnAlpha) && - (alpha.getWidth() == width) && + (alpha.getWidth() == width) && (alpha.getHeight() == height) ) { for (int i = 0; i < width*height; i++) @@ -326,12 +326,12 @@ void MyBitmap::allocate(int w, int h) BITMAPINFO bi; - bi.bmiHeader.biSize = sizeof(bi.bmiHeader); - bi.bmiHeader.biWidth = w; - bi.bmiHeader.biHeight = -h; - bi.bmiHeader.biPlanes = 1; - bi.bmiHeader.biBitCount = 32; - bi.bmiHeader.biCompression = BI_RGB; + bi.bmiHeader.biSize = sizeof(bi.bmiHeader); + bi.bmiHeader.biWidth = w; + bi.bmiHeader.biHeight = -h; + bi.bmiHeader.biPlanes = 1; + bi.bmiHeader.biBitCount = 32; + bi.bmiHeader.biCompression = BI_RGB; if (dcBmp) { @@ -339,9 +339,9 @@ void MyBitmap::allocate(int w, int h) DeleteDC(dcBmp); } - hBmp = (HBITMAP)CreateDIBSection(0, &bi, DIB_RGB_COLORS, (void **)&bits, 0, 0); - dcBmp = CreateCompatibleDC(0); - hBmpSave = (HBITMAP)SelectObject(dcBmp, hBmp); + hBmp = (HBITMAP)CreateDIBSection(0, &bi, DIB_RGB_COLORS, (void **)&bits, 0, 0); + dcBmp = CreateCompatibleDC(0); + hBmpSave = (HBITMAP)SelectObject(dcBmp, hBmp); } void MyBitmap::free() diff --git a/splashscreen/src/headers.h b/splashscreen/src/headers.h index d541462..78e87d4 100644 --- a/splashscreen/src/headers.h +++ b/splashscreen/src/headers.h @@ -69,6 +69,12 @@ #define MODNAME "SplashScreen" #define WM_LOADED (WM_USER + 10) +#ifdef _UNICODE + #define tmemcpy wmemcpy +#else + #define tmemcpy memcpy +#endif + struct SPLASHOPTS { byte active; diff --git a/splashscreen/src/main.cpp b/splashscreen/src/main.cpp index 45f7fae..4e18efd 100644 --- a/splashscreen/src/main.cpp +++ b/splashscreen/src/main.cpp @@ -56,7 +56,7 @@ BOOL (WINAPI *MyUpdateLayeredWindow) HANDLE hSplashThread, hModulesLoaded, hPlugDisableHook, hOptInit, hSystemOKToExit; PLUGININFOEX pluginInfo={ - sizeof(PLUGININFOEX), + sizeof(PLUGININFOEX), __PLUGIN_NAME, PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), __DESCRIPTION, @@ -66,7 +66,7 @@ PLUGININFOEX pluginInfo={ __AUTHORWEB, UNICODE_AWARE, 0, - MIID_SPLASHSCREEN + MIID_SPLASHSCREEN }; extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) @@ -83,7 +83,7 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvRe void SplashMain() { - if (bstartup) + if (bstartup) { // Retrive path to exe of current running Miranda is located szMirDir = Utils_ReplaceVarsT(_T("%miranda_path%")); @@ -123,7 +123,7 @@ void SplashMain() { hAdvaimg = LoadLibrary(szhAdvaimgPath); if (hAdvaimg == NULL) - { + { png2dibavail = false; bstartup = false; } @@ -206,10 +206,10 @@ void SplashMain() TCHAR szOldPath[MAX_PATH] = {0}; if(options.random) // randomly select a splash file - { + { int filescount = 0; TCHAR szSplashDir[MAX_PATH] = {0}, szSearch[MAX_PATH] = {0}; - TCHAR* p = 0; + TCHAR* p = 0; TCHAR files [255][50]; //TODO: make memory allocation dynamic lstrcpy(szSplashDir, szSplashFile); @@ -221,21 +221,21 @@ void SplashMain() mir_sntprintf(szSearch, SIZEOF(szSearch), _T("%s\\*.*"), szSplashDir); // FFFN will return filenames HANDLE hFind = INVALID_HANDLE_VALUE; - WIN32_FIND_DATA ffd; + WIN32_FIND_DATA ffd; hFind = FindFirstFile(szSearch, &ffd); if ( hFind != INVALID_HANDLE_VALUE ) { do { if (!(ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) - { + { #ifdef _DEBUG logMessage(_T("Found file"), ffd.cFileName); #endif //files = new char[strlen(ffd.cFileName)]; //files[filescount] = new char[strlen(ffd.cFileName)]; TCHAR ext[5]; - memcpy(ext, ffd.cFileName + (_tcslen(ffd.cFileName)-4), 5); + tmemcpy(ext, ffd.cFileName + (_tcslen(ffd.cFileName)-4), 5); #ifdef _DEBUG logMessage(_T("Extention"), ext); @@ -261,14 +261,11 @@ void SplashMain() logMessage(_T("final file"), szSplashFile); #endif FindClose(hFind); - } //if + } //if } // Call splash display routine ShowSplash(false); - - if (options.random) - lstrcpy(szSplashFile, szOldPath); } bstartup = false; } @@ -276,7 +273,7 @@ void SplashMain() int onSystemOKToExit(WPARAM wParam,LPARAM lParam) { // Hooked events need to be unhooked - UnhookEvent(hModulesLoaded); + UnhookEvent(hModulesLoaded); UnhookEvent(hSystemOKToExit); UnhookEvent(hPlugDisableHook); UnhookEvent(hOptInit); @@ -339,7 +336,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) #endif } } - + // Options initialize hook hOptInit = HookEvent(ME_OPT_INITIALISE, OptInit); @@ -376,7 +373,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) update.cpbVersion = (int)strlen((char *)update.pbVersion); update.szUpdateURL = UPDATER_AUTOREGISTER; - + // these are the three lines that matter - the archive, the page containing the version string, and the text (or data) // before the version that we use to locate it on the page // (note that if the update URL and the version URL point to standard file listing entries, the backend xml @@ -427,7 +424,7 @@ extern "C" int __declspec(dllexport) Unload(void) // Freeing loaded libraries if (hUserDll) FreeLibrary(hUserDll); if (hAdvaimg) FreeLibrary(hAdvaimg); - + #ifdef _DEBUG logMessage(_T("Unload"), _T("Job done")); #endif diff --git a/splashscreen/src/options.cpp b/splashscreen/src/options.cpp index a578d2b..b400eca 100644 --- a/splashscreen/src/options.cpp +++ b/splashscreen/src/options.cpp @@ -46,8 +46,8 @@ void ReadIniConfig() } BOOL Exists(LPCTSTR strName) -{ - return GetFileAttributes(strName) != INVALID_FILE_ATTRIBUTES; +{ + return GetFileAttributes(strName) != INVALID_FILE_ATTRIBUTES; } INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) @@ -55,9 +55,9 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP switch (msg) { case WM_INITDIALOG: - { + { TranslateDialogDefault(hwndDlg); - if (!png2dibavail) + if (!png2dibavail) { ShowWindow(GetDlgItem(hwndDlg, IDC_PNG2DIBWARN), SW_SHOW); EnableWindow(GetDlgItem(hwndDlg, IDC_ACTIVE), false); @@ -223,7 +223,7 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP TCHAR *pos; pos = _tcsrchr(szPath2Spash, _T('\\')); if (pos != NULL) - { + { *pos = 0; lstrcat(szPath2Spash, _T("\\")); } @@ -315,7 +315,7 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP GetWindowText(GetDlgItem(hwndDlg, IDC_SNDPATH), tmp, MAX_PATH); DBWriteContactSettingTString(NULL, MODNAME, "Sound", tmp); - + GetWindowText(GetDlgItem(hwndDlg, IDC_VERSIONPREFIX), tmp, MAX_PATH); DBWriteContactSettingTString(NULL, MODNAME, "VersionPrefix", tmp); lstrcpy(szPrefix, tmp); diff --git a/splashscreen/src/splash.cpp b/splashscreen/src/splash.cpp index a0389f2..05df53d 100644 --- a/splashscreen/src/splash.cpp +++ b/splashscreen/src/splash.cpp @@ -147,14 +147,14 @@ LRESULT CALLBACK SplashWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM case WM_PAINT: { if (!MyUpdateLayeredWindow) // Win 9x - { + { #ifdef _DEBUG logMessage(_T("WM_PAINT"), _T("painting..")); #endif PAINTSTRUCT ps; BeginPaint(hwndSplash, &ps); BitBlt(ps.hdc, 0, 0, SplashBmp->getWidth(), SplashBmp->getHeight(), tmpBmp->getDC(), 0, 0, SRCCOPY); - EndPaint(hwndSplash, &ps); + EndPaint(hwndSplash, &ps); } break; } @@ -174,10 +174,9 @@ int SplashThread(void *arg) if (options.playsnd) { TCHAR cmd[MAX_PATH]; - mir_sntprintf(cmd, SIZEOF(cmd), _T("open \"%s\" type mpegvideo alias %s"), szSoundFile, szSoundFile); - mciSendString(cmd, NULL, 0, 0); - mir_sntprintf(cmd, SIZEOF(cmd), _T("play %s from 0"), szSoundFile); + mir_sntprintf(cmd, SIZEOF(cmd), _T("open \"%s\" type mpegvideo alias song1"), szSoundFile); mciSendString(cmd, NULL, 0, 0); + mciSendString(_T("play song1"), NULL, 0, 0); } WNDCLASSEX wcl; @@ -243,55 +242,55 @@ int SplashThread(void *arg) int splashWidth = SplashBmp->getWidth(); for (i = 0; i < splashWidth; ++i) if (SplashBmp->getRow(0)[i] & 0xFF000000) - { - if (x < 0) - { - x = i-1; // 1 pixel for marker line - splashWithMarkers = true; - } else - { - x = -1; - splashWithMarkers = false; - break; - } - } - int splashHeight = SplashBmp->getHeight(); - for (i = 0; splashWithMarkers && (i < splashHeight); ++i) - if (SplashBmp->getRow(i)[0] & 0xFF000000) - { - if (y < 0) - { - y = i-1; // 1 pixel for marker line - splashWithMarkers = true; - } else - { - y = -1; - splashWithMarkers = false; - break; - } - } - - TCHAR verString[256] = {0}; - TCHAR* mirandaVerString = mir_a2t(szVersion); - mir_sntprintf(verString, SIZEOF(verString), _T("%s%s"), szPrefix, mirandaVerString); - mir_free(mirandaVerString); - LOGFONT lf = {0}; - lf.lfHeight = 14; - _tcscpy_s(lf.lfFaceName, _T("Verdana")); - SelectObject(SplashBmp->getDC(), CreateFontIndirect(&lf)); - if (!splashWithMarkers) - { - SIZE v_sz = {0,0}; - GetTextExtentPoint32(SplashBmp->getDC(), verString, (int)_tcslen(verString), &v_sz); - x = SplashBmp->getWidth()/2-(v_sz.cx/2); - y = SplashBmp->getHeight()-(SplashBmp->getHeight()*(100-90)/100); - } - - SetTextColor(SplashBmp->getDC(), (0xFFFFFFFFUL-SplashBmp->getRow(y)[x])&0x00FFFFFFUL); - //SplashBmp->DrawText(verString,SplashBmp->getWidth()/2-(v_sz.cx/2),SplashBmp->getHeight()-30); - SetBkMode(SplashBmp->getDC(), TRANSPARENT); - SplashBmp->DrawText(verString, x, y); - //free (ptr_verString); + { + if (x < 0) + { + x = i-1; // 1 pixel for marker line + splashWithMarkers = true; + } else + { + x = -1; + splashWithMarkers = false; + break; + } + } + int splashHeight = SplashBmp->getHeight(); + for (i = 0; splashWithMarkers && (i < splashHeight); ++i) + if(SplashBmp->getRow(i)[0] & 0xFF000000) + { + if (y < 0) + { + y = i-1; // 1 pixel for marker line + splashWithMarkers = true; + } else + { + y = -1; + splashWithMarkers = false; + break; + } + } + + TCHAR verString[256] = {0}; + TCHAR* mirandaVerString = mir_a2t(szVersion); + mir_sntprintf(verString, SIZEOF(verString), _T("%s%s"), szPrefix, mirandaVerString); + mir_free(mirandaVerString); + LOGFONT lf = {0}; + lf.lfHeight = 14; + _tcscpy_s(lf.lfFaceName, _T("Verdana")); + SelectObject(SplashBmp->getDC(), CreateFontIndirect(&lf)); + if (!splashWithMarkers) + { + SIZE v_sz = {0,0}; + GetTextExtentPoint32(SplashBmp->getDC(), verString, (int)_tcslen(verString), &v_sz); + x = SplashBmp->getWidth()/2-(v_sz.cx/2); + y = SplashBmp->getHeight()-(SplashBmp->getHeight()*(100-90)/100); + } + + SetTextColor(SplashBmp->getDC(), (0xFFFFFFFFUL-SplashBmp->getRow(y)[x])&0x00FFFFFFUL); + //SplashBmp->DrawText(verString,SplashBmp->getWidth()/2-(v_sz.cx/2),SplashBmp->getHeight()-30); + SetBkMode(SplashBmp->getDC(), TRANSPARENT); + SplashBmp->DrawText(verString, x, y); + //free (ptr_verString); } if (MyUpdateLayeredWindow) // Win 2000+ @@ -309,7 +308,7 @@ int SplashThread(void *arg) ShowWindow(hwndSplash, SW_SHOWNORMAL); } else // Win 9x - { + { tmpBmp = new MyBitmap(SplashBmp->getWidth(),SplashBmp->getHeight()); HDC dtDC = GetDC(GetDesktopWindow()); @@ -340,7 +339,7 @@ int SplashThread(void *arg) blend.SourceConstantAlpha = i; MyUpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA); Sleep(1); - } + } } blend.SourceConstantAlpha = 255; MyUpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA); @@ -366,26 +365,23 @@ int SplashThread(void *arg) } } - // The Message Pump - MSG msg; - while (GetMessage(&msg, NULL, 0, 0) == TRUE) //NULL means every window in the thread; == TRUE means a safe pump. - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - if (options.playsnd) + // The Message Pump + MSG msg; + while (GetMessage(&msg, NULL, 0, 0) == TRUE) //NULL means every window in the thread; == TRUE means a safe pump. { - TCHAR cmd[MAX_PATH]; - mir_sntprintf(cmd, SIZEOF(cmd), _T("close %s"), szSoundFile); - mciSendString(cmd, NULL, 0, 0); + TranslateMessage(&msg); + DispatchMessage(&msg); } - ExitThread(0); - return 1; + + if (options.playsnd) + mciSendString(_T("close song1"), NULL, 0, 0); + + ExitThread(0); + return 1; } BOOL ShowSplash(BOOL bpreview) -{ +{ if (bpreview && bpreviewruns) return 0; if (bpreview) bpreviewruns = true; @@ -416,8 +412,8 @@ BOOL ShowSplash(BOOL bpreview) #endif } else - { - timeout = options.showtime; + { + timeout = options.showtime; #ifdef _DEBUG TCHAR b [40]; mir_sntprintf(b, SIZEOF(b), _T("%d"), options.showtime); -- cgit v1.2.3