summaryrefslogtreecommitdiff
path: root/plugins/SplashScreen/src
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2012-05-15 10:38:20 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2012-05-15 10:38:20 +0000
commit48540940b6c28bb4378abfeb500ec45a625b37b6 (patch)
tree2ef294c0763e802f91d868bdef4229b6868527de /plugins/SplashScreen/src
parent5c350913f011e119127baeb32a6aedeb4f0d33bc (diff)
initial commit
git-svn-id: http://svn.miranda-ng.org/main/trunk@2 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SplashScreen/src')
-rw-r--r--plugins/SplashScreen/src/bitmap_funcs.cpp362
-rw-r--r--plugins/SplashScreen/src/bitmap_funcs.h77
-rw-r--r--plugins/SplashScreen/src/debug.h72
-rw-r--r--plugins/SplashScreen/src/headers.h119
-rw-r--r--plugins/SplashScreen/src/main.cpp433
-rw-r--r--plugins/SplashScreen/src/msvc6.rc2
-rw-r--r--plugins/SplashScreen/src/options.cpp448
-rw-r--r--plugins/SplashScreen/src/resource.h36
-rw-r--r--plugins/SplashScreen/src/services.cpp74
-rw-r--r--plugins/SplashScreen/src/splash.cpp434
-rw-r--r--plugins/SplashScreen/src/splash.rc152
-rw-r--r--plugins/SplashScreen/src/version.h30
-rw-r--r--plugins/SplashScreen/src/version.rc38
13 files changed, 2277 insertions, 0 deletions
diff --git a/plugins/SplashScreen/src/bitmap_funcs.cpp b/plugins/SplashScreen/src/bitmap_funcs.cpp
new file mode 100644
index 0000000000..09ded3aeb2
--- /dev/null
+++ b/plugins/SplashScreen/src/bitmap_funcs.cpp
@@ -0,0 +1,362 @@
+#include "headers.h"
+#include "bitmap_funcs.h"
+
+BOOL (WINAPI *_mempng2dib) (BYTE*, DWORD, BITMAPINFOHEADER**);
+
+MyBitmap::MyBitmap()
+{
+ dcBmp = 0;
+ hBmp = 0;
+ bits = 0;
+ width = height = 0;
+ bitsSave = 0;
+}
+
+MyBitmap::MyBitmap(int w, int h)
+{
+ dcBmp = 0;
+ hBmp = 0;
+ bits = 0;
+ width = height = 0;
+ bitsSave = 0;
+ allocate(w,h);
+}
+
+MyBitmap::MyBitmap(TCHAR *fn, TCHAR *fnAlpha)
+{
+ dcBmp = 0;
+ hBmp = 0;
+ bits = 0;
+ width = height = 0;
+ bitsSave = 0;
+ loadFromFile(fn, fnAlpha);
+}
+
+MyBitmap::~MyBitmap()
+{
+ if (bitsSave)
+ delete [] bitsSave;
+ free();
+}
+
+void MyBitmap::makeOpaque()
+{
+ if (!bits) return;
+
+ for (int i = 0; i < width*height; i++)
+ bits[i] |= 0xff000000;
+}
+
+void MyBitmap::saveAlpha(int x, int y, int w, int h)
+{
+ if (bitsSave)
+ delete [] bitsSave;
+
+ if (!w) w = width;
+ if (!h) h = height;
+
+ bitsSave = new COLOR32[w*h];
+ COLOR32 *p1 = bitsSave;
+
+ for (int i = 0; i < h; i++)
+ {
+ if (i+y < 0) continue;
+ if (i+y >= height) break;
+ COLOR32 *p2 = bits + (y+i)*width + x;
+ for (int j = 0; j < w; j++)
+ {
+ if (j+x < 0) continue;
+ if (j+x >= width) break;
+ *p1++ = *p2++;
+ }
+ }
+}
+
+void MyBitmap::restoreAlpha(int x, int y, int w, int h)
+{
+ if (!bitsSave)
+ return;
+
+ if (!w) w = width;
+ if (!h) h = height;
+
+ COLOR32 *p1 = bitsSave;
+
+ for (int i = 0; i < h; i++)
+ {
+ if (i+y < 0) continue;
+ if (i+y >= height) break;
+ COLOR32 *p2 = bits + (y+i)*width + x;
+ for (int j = 0; j < w; j++)
+ {
+ if (j+x < 0) continue;
+ if (j+x >= width) break;
+ if ((*p1&0x00ffffff) != (*p2&0x00ffffff))
+ {
+ *p2 |= 0xff000000;
+ } else
+ {
+ *p2 = (*p2&0x00ffffff) | (*p1&0xff000000);
+ }
+ ++p1;
+ ++p2;
+ }
+ }
+
+ delete [] bitsSave;
+ bitsSave = 0;
+}
+
+void MyBitmap::Blend(MyBitmap *bmp, int x, int y, int w, int h)
+{
+ if (!(bits && bmp && bmp->bits)) return;
+
+ if (!w) w = bmp->width;
+ if (!h) h = bmp->height;
+ float kx = (float)bmp->width / w;
+ float ky = (float)bmp->height / h;
+
+ if (x+w >= this->getWidth())
+ w = this->getWidth() - x;
+ if (y+h >= this->getHeight())
+ h = this->getHeight() - y;
+
+ for (int i = 0; i < h; i++)
+ {
+ if (i+y < 0) continue;
+ if (i+y >= height) break;
+ for (int j = 0; j < w; j++)
+ {
+ if (j+x < 0) continue;
+ if (j+x >= width) break;
+ COLOR32 src = bmp->bits[int(i*ky)*bmp->width + int(j*kx)];
+ COLOR32 dst = bits[(i+y)*width + (j+x)];
+ long alpha = geta(src);
+ bits[(i+y)*width + (j+x)] = rgba(
+ getr(src)+(255-alpha)*getr(dst)/255,
+ getg(src)+(255-alpha)*getg(dst)/255,
+ getb(src)+(255-alpha)*getb(dst)/255,
+ geta(src)+(255-alpha)*geta(dst)/255
+ );
+ }
+ }
+}
+
+void MyBitmap::DrawText(TCHAR *str, int x, int y)
+{
+ SIZE sz; GetTextExtentPoint32(this->getDC(), str, lstrlen(str), &sz);
+ RECT rc; SetRect(&rc, x, y, x+10000, y+10000);
+ this->saveAlpha(x-2,y-2,sz.cx+2,sz.cy+2);
+ ::DrawText(this->getDC(), str, (int)_tcslen(str), &rc, DT_LEFT | DT_TOP | DT_SINGLELINE | DT_NOPREFIX);
+ this->restoreAlpha(x-2,y-2,sz.cx+2,sz.cy+2);
+ //(x,y,sz.cx,sz.cy);
+}
+
+HRGN MyBitmap::buildOpaqueRgn()
+{
+ return CreateRectRgn(0, 0, width, height);
+
+ //
+ int i, rectCount = 0;
+ for (i = 0; i < width*height; i++)
+ if (((bits[i] >> 24)&0xff) >= 128)
+ rectCount++;
+
+ RGNDATA *rgnData = (RGNDATA *)malloc(sizeof(RGNDATAHEADER) + rectCount * sizeof(RECT));
+ rgnData->rdh.dwSize = sizeof(RGNDATAHEADER);
+ rgnData->rdh.iType = RDH_RECTANGLES;
+ rgnData->rdh.nCount = rectCount;
+ rgnData->rdh.nRgnSize = rectCount * sizeof(RECT);
+ SetRect(&(rgnData->rdh.rcBound), 0, 0, width, height);
+
+ char *p = (char *)&(rgnData->Buffer);
+ for (i = 0; i < width*height; i++)
+ if (((bits[i] >> 24)&0xff) >= 128)
+ {
+ SetRect((LPRECT)p, i%width,i/width,i%width+1,i/width+1);
+ p += sizeof(RECT);
+ }
+
+ HRGN rgn = ExtCreateRegion(NULL, sizeof(RGNDATAHEADER) + rectCount * sizeof(RECT), rgnData);
+ ::free(rgnData);
+
+ return rgn;
+}
+
+bool MyBitmap::loadFromFile(TCHAR *fn, TCHAR *fnAlpha)
+{
+ if (bits) free();
+
+ SIZE sz;
+
+ TCHAR *ext;
+ ext = &fn[lstrlen(fn)-4];
+
+ if (!lstrcmpi(ext, _T(".png")))
+ {
+ HANDLE hFile, hMap = NULL;
+ BYTE* ppMap = NULL;
+ long cbFileSize = 0;
+ BITMAPINFOHEADER* pDib;
+ BYTE* pDibBits = 0;
+
+ 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)
+ cbFileSize = GetFileSize(hFile, NULL);
+ if ( cbFileSize != 0 )
+ {
+ PNG2DIB param;
+ param.pSource = ppMap;
+ param.cbSourceSize = cbFileSize;
+ param.pResult = &pDib;
+
+ if (png2dibConvertor((char*)param.pSource, param.cbSourceSize, param.pResult))
+ pDibBits = (BYTE*)(pDib+1);
+ else
+ cbFileSize = 0;
+ #ifdef _DEBUG
+ logMessage(_T("Loading splash file"), _T("done"));
+ #endif
+ }
+
+ if (ppMap) UnmapViewOfFile(ppMap);
+ if (hMap) CloseHandle(hMap);
+ if (hFile) CloseHandle(hFile);
+
+ if (!cbFileSize) return false;
+
+ BITMAPINFO *bi=(BITMAPINFO*)pDib;
+ BYTE *pt=(BYTE*)bi;
+ pt+=bi->bmiHeader.biSize;
+ HBITMAP hBitmap = NULL;
+
+ if (bi->bmiHeader.biBitCount!=32)
+ {
+ allocate(abs(bi->bmiHeader.biWidth), abs(bi->bmiHeader.biHeight));
+ HDC hdcTmp = CreateCompatibleDC(getDC());
+ HBITMAP hBitmap = CreateDIBitmap(getDC(), pDib, CBM_INIT, pDibBits, bi, DIB_PAL_COLORS);
+ SelectObject(hdcTmp, hBitmap);
+ BitBlt(this->getDC(), 0, 0, abs(bi->bmiHeader.biWidth), abs(bi->bmiHeader.biHeight), hdcTmp, 0, 0, SRCCOPY);
+ this->makeOpaque();
+ DeleteDC(hdcTmp);
+ DeleteObject(hBitmap);
+
+ }
+ else
+ {
+ BYTE *ptPixels = pt;
+ hBitmap = CreateDIBSection(NULL, bi, DIB_RGB_COLORS, (void **)&ptPixels, NULL, 0);
+ memcpy(ptPixels,pt,bi->bmiHeader.biSizeImage);
+
+ allocate(abs(bi->bmiHeader.biWidth), abs(bi->bmiHeader.biHeight));
+ //memcpy(bits, pt, bi->bmiHeader.biSizeImage);
+
+ BYTE *p2=(BYTE *)pt;
+ for (int y=0; y<bi->bmiHeader.biHeight; ++y)
+ {
+ BYTE *p1=(BYTE *)bits + (bi->bmiHeader.biHeight-y-1)*bi->bmiHeader.biWidth*4;
+ for (int x=0; x<bi->bmiHeader.biWidth; ++x)
+ {
+ p1[0]= p2[0];
+ p1[1]= p2[1];
+ p1[2]= p2[2];
+ p1[3]= p2[3];
+ p1 += 4;
+ p2 += 4;
+ }
+ }
+
+ premultipleChannels();
+ }
+
+ GlobalFree(pDib);
+ DeleteObject(hBitmap);
+ return true;
+ } else
+ {
+ HBITMAP hBmpLoaded = (HBITMAP)LoadImage(NULL, fn, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
+ if (!hBmpLoaded)
+ {
+ #ifdef _DEBUG
+ logMessage(_T("MyBitmap::loadFromFile"), _T("Bitmap load failed"));
+ #endif
+ return false;
+ }
+
+ BITMAP bm; GetObject(hBmpLoaded, sizeof(bm), &bm);
+ SetBitmapDimensionEx(hBmpLoaded, bm.bmWidth, bm.bmHeight, NULL);
+
+ HDC dcTmp = CreateCompatibleDC(0);
+ GetBitmapDimensionEx(hBmpLoaded, &sz);
+ HBITMAP hBmpDcSave = (HBITMAP)SelectObject(dcTmp, hBmpLoaded);
+
+ allocate(sz.cx, sz.cy);
+ BitBlt(dcBmp, 0, 0, width, height, dcTmp, 0, 0, SRCCOPY);
+
+ DeleteObject(SelectObject(dcTmp, hBmpDcSave));
+ DeleteDC(dcTmp);
+
+ MyBitmap alpha;
+ if (fnAlpha && alpha.loadFromFile(fnAlpha) &&
+ (alpha.getWidth() == width) &&
+ (alpha.getHeight() == height) )
+ {
+ for (int i = 0; i < width*height; i++)
+ bits[i] = (bits[i] & 0x00ffffff) | ( (alpha.bits[i] & 0x000000ff) << 24 );
+ premultipleChannels();
+ } else
+ {
+ makeOpaque();
+ }
+ return true;
+ }
+ // unreachable place
+ return false;
+}
+
+void MyBitmap::allocate(int w, int h)
+{
+ width = w;
+ height = 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;
+
+ if (dcBmp)
+ {
+ DeleteObject(SelectObject(dcBmp, hBmpSave));
+ DeleteDC(dcBmp);
+ }
+
+ hBmp = (HBITMAP)CreateDIBSection(0, &bi, DIB_RGB_COLORS, (void **)&bits, 0, 0);
+ dcBmp = CreateCompatibleDC(0);
+ hBmpSave = (HBITMAP)SelectObject(dcBmp, hBmp);
+}
+
+void MyBitmap::free()
+{
+ DeleteObject(SelectObject(dcBmp, hBmpSave));
+ DeleteDC(dcBmp);
+
+ dcBmp = 0;
+ hBmp = 0;
+ bits = 0;
+ width = height = 0;
+}
+
+void MyBitmap::premultipleChannels()
+{
+ for (int i = 0; i < width*height; i++)
+ bits[i] = rgba(getr(bits[i])*geta(bits[i])/255, getg(bits[i])*geta(bits[i])/255, getb(bits[i])*geta(bits[i])/255, geta(bits[i]));
+} \ No newline at end of file
diff --git a/plugins/SplashScreen/src/bitmap_funcs.h b/plugins/SplashScreen/src/bitmap_funcs.h
new file mode 100644
index 0000000000..f82e909ad2
--- /dev/null
+++ b/plugins/SplashScreen/src/bitmap_funcs.h
@@ -0,0 +1,77 @@
+#ifndef __bitmap_funcs_h__
+#define __bitmap_funcs_h__
+
+// This should make bitmap manipulations much easier...
+class MyBitmap
+{
+public:
+ typedef unsigned long COLOR32;
+ static inline COLOR32 RGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 0xff)
+ {
+ return (a << 24) | (r << 16) | (g << 8) | b;
+ };
+
+private:
+ HBITMAP hBmpSave, hBmp;
+ HDC dcBmp;
+ COLOR32 *bits;
+ COLOR32 *bitsSave;
+ int width, height;
+
+ void allocate(int w, int h);
+ void free();
+
+ void premultipleChannels();
+
+public:
+ MyBitmap();
+ MyBitmap(int w, int h);
+ MyBitmap(TCHAR *fn, TCHAR *fnAlpha = 0);
+ ~MyBitmap();
+
+ bool loadFromFile(TCHAR *fn, TCHAR *fnAlpha = 0);
+
+ int getWidth() { return width; }
+ int getHeight() { return height; }
+
+ HDC getDC() { return dcBmp; }
+ HBITMAP getBitmap() { return hBmp; }
+
+
+ void makeOpaque();
+
+ void saveAlpha(int x = 0, int y = 0, int w = 0, int h = 0);
+ void restoreAlpha(int x = 0, int y = 0, int w = 0, int h = 0);
+
+ void Blend(MyBitmap *bmp, int x, int y, int w, int h);
+ void DrawText(TCHAR *str, int x, int y);
+
+ inline COLOR32 *getBits() { return bits; }
+ inline COLOR32 *getRow(int row) { return bits + row * width; }
+ inline COLOR32 *operator[] (int row) { return bits + row * width; }
+
+ COLOR32 rgba(COLOR32 r, COLOR32 g, COLOR32 b, COLOR32 a)
+ {
+ return ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff);
+ }
+ COLOR32 getr(COLOR32 c)
+ {
+ return (c >> 16) & 0xff;
+ }
+ COLOR32 getg(COLOR32 c)
+ {
+ return (c >> 8) & 0xff;
+ }
+ COLOR32 getb(COLOR32 c)
+ {
+ return c & 0xff;
+ }
+ COLOR32 geta(COLOR32 c)
+ {
+ return (c >> 24) & 0xff;
+ }
+
+ HRGN buildOpaqueRgn();
+};
+
+#endif // __bitmap_funcs_h__
diff --git a/plugins/SplashScreen/src/debug.h b/plugins/SplashScreen/src/debug.h
new file mode 100644
index 0000000000..70c44e250e
--- /dev/null
+++ b/plugins/SplashScreen/src/debug.h
@@ -0,0 +1,72 @@
+#ifndef __debug_h__
+#define __debug_h__
+
+#define PlugName "SplashScreen"
+extern TCHAR szLogFile[MAX_PATH];
+
+/*
+ * output a notification message.
+ * may accept a hContact to include the contacts nickname in the notification message...
+ * the actual message is using printf() rules for formatting and passing the arguments...
+ *
+ */
+
+int inline _DebugPopup(HANDLE hContact, TCHAR *fmt, ...)
+{
+ POPUPDATAT ppd;
+ va_list va;
+ TCHAR debug[1024];
+
+ va_start(va, fmt);
+ mir_sntprintf(debug, SIZEOF(debug), fmt, va);
+
+ if(CallService(MS_POPUP_QUERY, PUQS_GETSTATUS, 0) == 1)
+ {
+ ZeroMemory((void *)&ppd, sizeof(ppd));
+ ppd.lchContact = hContact;
+ ppd.lchIcon = LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
+ if(hContact != 0)
+ _tcsncpy_s(ppd.lptzContactName, (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR), MAX_CONTACTNAME);
+ else
+ _tcsncpy_s(ppd.lptzContactName, _T(PlugName), MAX_CONTACTNAME);
+ _tcsncpy_s(ppd.lptzText, debug, MAX_SECONDLINE - 20);
+ ppd.colorText = RGB(255,255,255);
+ ppd.colorBack = RGB(255,0,0);
+ CallService(MS_POPUP_ADDPOPUP, (WPARAM)&ppd, 0);
+ }
+ return 0;
+}
+
+/*
+ * initialize logfile
+ */
+
+int inline initLog()
+{
+ fclose(_tfopen(szLogFile, _T("w")));
+ return 0;
+}
+
+/*
+ * log timestamp
+ */
+
+void inline logTimeStamp()
+{
+ FILE *f = _tfopen(szLogFile, _T("a"));
+ _ftprintf(f, _T("Time:\t\t\t\t%s\n"), _T(__TIME__));
+ fclose(f);
+}
+
+/*
+ * logging func
+ */
+
+void inline logMessage(TCHAR *func, TCHAR *msg)
+{
+ FILE *f = _tfopen(szLogFile, _T("a"));
+ _ftprintf(f, _T("%s:\t\t%s\n"), func, msg);
+ fclose(f);
+}
+
+#endif // __debug_h__ \ No newline at end of file
diff --git a/plugins/SplashScreen/src/headers.h b/plugins/SplashScreen/src/headers.h
new file mode 100644
index 0000000000..78e87d40d4
--- /dev/null
+++ b/plugins/SplashScreen/src/headers.h
@@ -0,0 +1,119 @@
+/*
+ Splash Screen Plugin for Miranda-IM (www.miranda-im.org)
+ (c) 2004-2007 nullbie, (c) 2005-2007 Thief
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ File name : $URL: http://svn.miranda.im/mainrepo/splashscreen/trunk/src/headers.h $
+ Revision : $Rev: 1587 $
+ Last change on : $Date: 2010-04-09 14:01:30 +0400 (Пт, 09 апр 2010) $
+ Last change by : $Author: Thief $
+*/
+
+#ifndef HEADERS_H
+#define HEADERS_H
+
+#define MIRANDA_VER 0x0900
+#define MIRANDA_CUSTOM_LP
+
+#define _WIN32_WINNT 0x0500
+#define WINVER 0x0400
+#define AC_SRC_ALPHA 0x01
+#define OEMRESOURCE
+#define _CRT_SECURE_NO_DEPRECATE
+
+#include <windows.h>
+#include <stdio.h>
+#include <commctrl.h>
+#include <time.h>
+#include <mmsystem.h>
+
+// Miranda API headers
+#include <win2k.h>
+#include <newpluginapi.h>
+#include <m_database.h>
+#include <m_options.h>
+#include <m_utils.h>
+#include <m_langpack.h>
+#include <m_system.h>
+#include <m_png.h>
+#include "m_updater.h"
+#include "m_splash.h"
+
+// Common headers
+#include "version.h"
+#include "resource.h"
+#include "bitmap_funcs.h"
+
+#ifdef _DEBUG
+ #include <m_clist.h>
+ #include <m_skin.h>
+ #include <m_popup.h>
+ #include "debug.h"
+#endif
+
+// Internal defines
+#define SPLASH_CLASS "MirandaSplash"
+#define MODNAME "SplashScreen"
+#define WM_LOADED (WM_USER + 10)
+
+#ifdef _UNICODE
+ #define tmemcpy wmemcpy
+#else
+ #define tmemcpy memcpy
+#endif
+
+struct SPLASHOPTS
+{
+ byte active;
+ byte playsnd;
+ byte loopsnd;
+ byte runonce;
+ byte fadein;
+ byte fadeout;
+ byte inheritGS;
+ byte random;
+ byte showversion;
+ byte fontsize;
+ int showtime;
+ int fosteps;
+ int fisteps;
+};
+
+extern HWND hwndSplash;
+extern SPLASHOPTS options;
+extern TCHAR szSplashFile[MAX_PATH], szSoundFile[MAX_PATH], szPrefix[128];
+extern TCHAR *szMirDir;
+extern char szVersion[MAX_PATH];
+extern BOOL bserviceinvoked, bmodulesloaded, png2dibavail;
+extern HANDLE hSplashThread;
+extern HINSTANCE hInst;
+
+extern BOOL (WINAPI *MyUpdateLayeredWindow)
+ (HWND hwnd, HDC hdcDST, POINT *pptDst, SIZE *psize, HDC hdcSrc, POINT *pptSrc,
+ COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags);
+// png2dib interface
+typedef BOOL ( *pfnConvertPng2dib )( char*, size_t, BITMAPINFOHEADER** );
+extern pfnConvertPng2dib png2dibConvertor;
+
+extern int OptInit(WPARAM wParam, LPARAM lParam);
+extern BOOL ShowSplash(BOOL bpreview);
+extern VOID ReadIniConfig();
+extern INT_PTR ShowSplashService(WPARAM wparam,LPARAM lparam);
+#ifdef _DEBUG
+ extern INT_PTR TestService(WPARAM wParam,LPARAM lParam);
+#endif
+
+#endif //HEADERS_H
diff --git a/plugins/SplashScreen/src/main.cpp b/plugins/SplashScreen/src/main.cpp
new file mode 100644
index 0000000000..4e18efd5b7
--- /dev/null
+++ b/plugins/SplashScreen/src/main.cpp
@@ -0,0 +1,433 @@
+/*
+ Splash Screen Plugin for Miranda-IM (www.miranda-im.org)
+ (c) 2004-2007 nullbie, (c) 2005-2007 Thief
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ File name : $URL: http://svn.miranda.im/mainrepo/splashscreen/trunk/src/main.cpp $
+ Revision : $Rev: 1586 $
+ Last change on : $Date: 2010-04-09 13:34:01 +0400 (Пт, 09 апр 2010) $
+ Last change by : $Author: Thief $
+
+*/
+
+#include "headers.h"
+
+HINSTANCE hInst = 0;
+PLUGINLINK *pluginLink;
+struct MM_INTERFACE mmi;
+int hLangpack;
+
+static HMODULE hUserDll = NULL;
+static HMODULE hAdvaimg = NULL;
+
+pfnConvertPng2dib png2dibConvertor = NULL;
+
+BOOL bstartup = true; // startup?
+BOOL bserviceinvoked = false;
+BOOL bmodulesloaded = false; // modules are loaded
+BOOL png2dibavail = true; // can we use png2dib service?
+
+// path to miranda's dir, config file path, splash path, sound path
+TCHAR szDllName[MAX_PATH], szSplashFile[MAX_PATH], szSoundFile[MAX_PATH], szhAdvaimgPath[MAX_PATH], szPrefix[128], inBuf[80];
+TCHAR * szMirDir;
+char szVersion[MAX_PATH];
+HANDLE hShowSplashService, hTestService;
+#ifdef _DEBUG
+ TCHAR szLogFile[MAX_PATH];
+#endif
+SPLASHOPTS options;
+HWND hwndSplash;
+BOOL (WINAPI *MyUpdateLayeredWindow)
+ (HWND hwnd, HDC hdcDST, POINT *pptDst, SIZE *psize, HDC hdcSrc, POINT *pptSrc,
+ COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags);
+HANDLE hSplashThread, hModulesLoaded, hPlugDisableHook, hOptInit, hSystemOKToExit;
+
+PLUGININFOEX pluginInfo={
+ sizeof(PLUGININFOEX),
+ __PLUGIN_NAME,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __DESCRIPTION,
+ __AUTHOR,
+ __AUTHOREMAIL,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ UNICODE_AWARE,
+ 0,
+ MIID_SPLASHSCREEN
+};
+
+extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void)
+{
+ static const MUUID interfaces[] = {MIID_SPLASHSCREEN, MIID_LAST};
+ return interfaces;
+}
+
+extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ hInst = hinstDLL;
+ return TRUE;
+}
+
+void SplashMain()
+{
+ if (bstartup)
+ {
+ // Retrive path to exe of current running Miranda is located
+ szMirDir = Utils_ReplaceVarsT(_T("%miranda_path%"));
+ mir_sntprintf(szhAdvaimgPath, SIZEOF(szhAdvaimgPath), _T("%s\\plugins\\advaimg.dll"), szMirDir);
+ CallService(MS_SYSTEM_GETVERSIONTEXT, MAX_PATH, (LPARAM)szVersion);
+
+ #ifdef _DEBUG
+ mir_sntprintf(szLogFile, SIZEOF(szLogFile), _T("%s\\%s.log"), szMirDir, _T(__INTERNAL_NAME));
+ initLog();
+ logTimeStamp();
+ TCHAR* mirandaVerString = mir_a2t(szVersion);
+ logMessage(_T("Miranda version"), mirandaVerString);
+ mir_free(mirandaVerString);
+ logMessage(_T("Dll Name"), _T(__FILENAME));
+ logMessage(_T("Advaimg path"), szhAdvaimgPath);
+ #endif
+
+ ReadIniConfig();
+ }
+
+ if (bstartup & (options.active == 1))
+ {
+ if (options.runonce)
+ {
+ DBWriteContactSettingByte(NULL, MODNAME, "Active", 0);
+ DBWriteContactSettingByte(NULL, MODNAME, "DisableAfterStartup", 0);
+ }
+
+ if (hUserDll == NULL)
+ {
+ hUserDll = LoadLibrary(_T("user32.dll"));
+ if (hUserDll)
+ MyUpdateLayeredWindow = (BOOL (WINAPI *)(HWND, HDC, POINT *, SIZE *, HDC, POINT *, COLORREF, BLENDFUNCTION *, DWORD))GetProcAddress(hUserDll, "UpdateLayeredWindow");
+ }
+
+ if (hAdvaimg == NULL)
+ {
+ hAdvaimg = LoadLibrary(szhAdvaimgPath);
+ if (hAdvaimg == NULL)
+ {
+ png2dibavail = false;
+ bstartup = false;
+ }
+ if (hAdvaimg)
+ {
+ png2dibConvertor = (pfnConvertPng2dib) GetProcAddress(hAdvaimg, "mempng2dib");
+ if (png2dibConvertor == NULL)
+ {
+ FreeLibrary(hAdvaimg); hAdvaimg = NULL;
+ MessageBox(NULL,
+ _T("Your advaimg.dll is either obsolete or damaged. Get latest from Miranda alpha builds."),
+ _T("Error"),
+ MB_OK | MB_ICONSTOP);
+ }
+ #ifdef _DEBUG
+ if (png2dibConvertor)
+ logMessage(_T("Loading advaimg"), _T("done"));
+ #endif
+ }
+ }
+
+ //for 9x "alfa" testing
+ //MyUpdateLayeredWindow = 0;
+ DBVARIANT dbv = {0};
+ DBGetContactSettingTString(NULL, MODNAME, "VersionPrefix", &dbv);
+ if (lstrcmp(dbv.ptszVal, NULL) == 0)
+ {
+ _tcscpy_s(szPrefix, _T(""));
+ DBFreeVariant(&dbv);
+ }
+ else
+ _tcscpy_s(szPrefix, dbv.ptszVal);
+ dbv.ptszVal = NULL;
+
+ DBGetContactSettingTString(NULL, MODNAME, "Path", &dbv);
+ if (lstrcmp(dbv.ptszVal, NULL) == 0)
+ {
+ _tcscpy_s(inBuf, _T("splash\\splash.png"));
+ DBFreeVariant(&dbv);
+ }
+ else
+ _tcscpy_s(inBuf, dbv.ptszVal);
+ dbv.ptszVal = NULL;
+
+ TCHAR szExpandedSplashFile[MAX_PATH];
+ ExpandEnvironmentStrings(inBuf, szExpandedSplashFile, SIZEOF(szExpandedSplashFile));
+ lstrcpy(inBuf, szExpandedSplashFile);
+
+ TCHAR *pos3 = 0;
+ pos3 = _tcsrchr(inBuf, _T(':'));
+ if (pos3 == NULL)
+ mir_sntprintf(szSplashFile, SIZEOF(szSplashFile), _T("%s\\%s"), szMirDir, inBuf);
+ else
+ lstrcpy(szSplashFile, inBuf);
+
+ DBGetContactSettingTString(NULL, MODNAME, "Sound", &dbv);
+ if (lstrcmp(dbv.ptszVal, NULL) == 0)
+ {
+ _tcscpy_s(inBuf, _T("sounds\\startup.wav"));
+ DBFreeVariant(&dbv);
+ }
+ else
+ _tcscpy_s(inBuf, dbv.ptszVal);
+
+ TCHAR szExpandedSoundFile[MAX_PATH];
+ ExpandEnvironmentStrings(inBuf, szExpandedSoundFile, SIZEOF(szExpandedSoundFile));
+ lstrcpy(inBuf, szExpandedSoundFile);
+
+ TCHAR *pos2;
+ pos2 = _tcschr(inBuf, _T(':'));
+ if (pos2 == NULL)
+ mir_sntprintf(szSoundFile, SIZEOF(szSoundFile), _T("%s\\%s"), szMirDir, inBuf);
+ else
+ lstrcpy(szSoundFile, inBuf);
+
+ #ifdef _DEBUG
+ logMessage(_T("SoundFilePath"), szSoundFile);
+ #endif
+
+ 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 files [255][50]; //TODO: make memory allocation dynamic
+
+ lstrcpy(szSplashDir, szSplashFile);
+ lstrcpy(szOldPath, szSplashFile);
+ // find the last \ and null it out, this leaves no trailing slash
+ p = _tcsrchr(szSplashDir, _T('\\'));
+ if (p) *p = 0;
+ // create the search filter
+ mir_sntprintf(szSearch, SIZEOF(szSearch), _T("%s\\*.*"), szSplashDir);
+ // FFFN will return filenames
+ HANDLE hFind = INVALID_HANDLE_VALUE;
+ 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];
+ tmemcpy(ext, ffd.cFileName + (_tcslen(ffd.cFileName)-4), 5);
+
+ #ifdef _DEBUG
+ logMessage(_T("Extention"), ext);
+ #endif
+
+ if (lstrcmpi(ext, _T(".png")) & lstrcmpi(ext, _T(".bmp")))
+ continue;
+
+ #ifdef _DEBUG
+ logMessage(_T("File has valid ext"), ext);
+ #endif
+ _tcscpy_s(files[filescount++], ffd.cFileName);
+ } //if
+ } while (FindNextFile(hFind, &ffd));
+
+ srand((unsigned) time(NULL));
+ int r = 0;
+ if (filescount) r = (rand() % filescount) + 1;
+
+ mir_sntprintf(szSplashFile, SIZEOF(szSplashFile), _T("%s\\%s"), szSplashDir, files[r-1]);
+
+ #ifdef _DEBUG
+ logMessage(_T("final file"), szSplashFile);
+ #endif
+ FindClose(hFind);
+ } //if
+ }
+
+ // Call splash display routine
+ ShowSplash(false);
+ }
+ bstartup = false;
+}
+
+int onSystemOKToExit(WPARAM wParam,LPARAM lParam)
+{
+ // Hooked events need to be unhooked
+ UnhookEvent(hModulesLoaded);
+ UnhookEvent(hSystemOKToExit);
+ UnhookEvent(hPlugDisableHook);
+ UnhookEvent(hOptInit);
+
+ DestroyServiceFunction(hShowSplashService);
+ #ifdef _DEBUG
+ DestroyServiceFunction(hTestService);
+ #endif
+
+ return 0;
+}
+
+int PlugDisableHook(WPARAM wParam, LPARAM lParam)
+{
+ #ifdef _DEBUG
+ TCHAR buf [128];
+ #endif
+ DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam;
+ TCHAR * tszModule= mir_a2t(cws->szModule), *tszSetting = mir_a2t(cws->szSetting);
+ if(options.inheritGS)
+ {
+ if (!lstrcmp(tszModule, _T("Skin")) & !lstrcmp(tszSetting, _T("UseSound")))
+ {
+ DBWriteContactSettingByte(NULL, MODNAME, "PlaySound", cws->value.bVal);
+ #ifdef _DEBUG
+ cws->value.bVal ? _DebugPopup(NULL, _T("Sounds enabled."), _T("")) : _DebugPopup(NULL, _T("Sounds disabled."), _T(""));
+ logMessage(_T("Module"), tszModule);
+ logMessage(_T("Setting"), tszSetting);
+ logMessage(_T("Value"), _itot(cws->value.bVal, buf, 10));
+ #endif
+ }
+ if (!lstrcmp(tszModule, _T("PluginDisable")) & (!lstrcmp(tszSetting, szDllName)))
+ {
+ DBWriteContactSettingByte(NULL, MODNAME, "Active", cws->value.bVal);
+ #ifdef _DEBUG
+ cws->value.bVal ? _DebugPopup(NULL, _T("Disabled."), "") : _DebugPopup(NULL, _T("Enabled."), _T(""));
+ logMessage(_T("PlugDisableHook"), _T("Triggered"));
+ logMessage(_T("Module"), tszModule);
+ logMessage(_T("Setting"), tszSetting);
+ logMessage(_T("Value"), _itot(cws->value.bVal, buf, 10));
+ #endif
+ }
+ }
+ mir_free(tszModule);
+ mir_free(tszSetting);
+
+ return 0;
+}
+
+int ModulesLoaded(WPARAM wParam, LPARAM lParam)
+{
+ bmodulesloaded = true; // all modules are loaded now, let other parts know about this fact
+
+ if (hwndSplash)
+ {
+ if (PostMessage(hwndSplash, WM_LOADED, 0, 0))
+ {
+ #ifdef _DEBUG
+ logMessage(_T("Posted WM_LOADED message"), _T("done"));
+ #endif
+ }
+ }
+
+ // Options initialize hook
+ hOptInit = HookEvent(ME_OPT_INITIALISE, OptInit);
+
+ hPlugDisableHook = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, PlugDisableHook);
+
+ // Service to call splash
+ hShowSplashService = CreateServiceFunction(MS_SHOWSPLASH, ShowSplashService);
+
+ #ifdef _DEBUG
+ hTestService = CreateServiceFunction("Splash/Test", TestService);
+ CLISTMENUITEM mi;
+ ZeroMemory(&mi,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.flags = CMIF_TCHAR;
+ mi.hIcon = LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
+ mi.hotKey = 0;
+ mi.position = -0x7FFFFFFF;
+ mi.ptszName = _T("Call Splash Service");
+ mi.pszService = "Splash/Test";
+
+ CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
+ #endif
+
+ if (ServiceExists(MS_UPDATE_REGISTER))
+ {
+ // register with updater
+ Update update = {0};
+ char szVersion[16];
+
+ update.cbSize = sizeof(Update);
+
+ update.szComponentName = pluginInfo.shortName;
+ update.pbVersion = (BYTE *)CreateVersionString(pluginInfo.version, szVersion);
+ 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
+ // data will be used to check for updates rather than the actual web page - this is not true for beta urls)
+ update.szBetaUpdateURL = "http://thief.miranda.im/advsplashscreen.zip";
+ update.szBetaVersionURL = "http://thief.miranda.im/updater/splash_version.txt";
+ update.szBetaChangelogURL = "http://thief.miranda.im";
+ update.pbBetaVersionPrefix = (BYTE *)"Splash Screen ";
+
+ update.cpbBetaVersionPrefix = (int)strlen((char *)update.pbBetaVersionPrefix);
+
+ CallService(MS_UPDATE_REGISTER, 0, (WPARAM)&update);
+ }
+
+ #ifdef _DEBUG
+ logMessage(_T("Loading modules"), _T("done"));
+ #endif
+
+ return 0;
+}
+
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+{
+ return &pluginInfo;
+}
+
+extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
+{
+ pluginLink = link;
+ mir_getLP(&pluginInfo);
+ mir_getMMI(&mmi);
+
+ hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
+ hSystemOKToExit = HookEvent(ME_SYSTEM_OKTOEXIT,onSystemOKToExit);
+
+ SplashMain();
+ mir_free(szMirDir);
+
+ return 0;
+}
+
+extern "C" int __declspec(dllexport) Unload(void)
+{
+ if (hSplashThread) CloseHandle(hSplashThread);
+
+ UnregisterClass(_T(SPLASH_CLASS), hInst);
+
+ // Freeing loaded libraries
+ if (hUserDll) FreeLibrary(hUserDll);
+ if (hAdvaimg) FreeLibrary(hAdvaimg);
+
+ #ifdef _DEBUG
+ logMessage(_T("Unload"), _T("Job done"));
+ #endif
+
+ return 0;
+} \ No newline at end of file
diff --git a/plugins/SplashScreen/src/msvc6.rc b/plugins/SplashScreen/src/msvc6.rc
new file mode 100644
index 0000000000..e79d7e3a96
--- /dev/null
+++ b/plugins/SplashScreen/src/msvc6.rc
@@ -0,0 +1,2 @@
+#include "splash.rc"
+#include "version.rc"
diff --git a/plugins/SplashScreen/src/options.cpp b/plugins/SplashScreen/src/options.cpp
new file mode 100644
index 0000000000..b400eca26d
--- /dev/null
+++ b/plugins/SplashScreen/src/options.cpp
@@ -0,0 +1,448 @@
+/*
+Splash Screen Plugin for Miranda-IM (www.miranda-im.org)
+(c) 2004-2007 nullbie, (c) 2005-2007 Thief
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+File name : $URL: http://svn.miranda.im/mainrepo/splashscreen/trunk/src/options.cpp $
+Revision : $Rev: 951 $
+Last change on : $Date: 2007-10-16 18:46:53 +0400 (Вт, 16 окт 2007) $
+Last change by : $Author: Thief $
+
+DESCRIPTION: Options dialog handling code
+
+*/
+
+#include "headers.h"
+
+TCHAR szPath2Spash [MAX_PATH], szSoundFilePath[MAX_PATH];
+
+// Reads values from db
+void ReadIniConfig()
+{
+ options.active = DBGetContactSettingByte(NULL, MODNAME, "Active", 1);
+ options.playsnd = DBGetContactSettingByte(NULL, MODNAME, "PlaySound", 0);
+ options.fadein = DBGetContactSettingByte(NULL, MODNAME, "FadeIn", 1);
+ options.fadeout = DBGetContactSettingByte(NULL, MODNAME, "FadeOut", 1);
+ options.showtime = DBGetContactSettingDword(NULL, MODNAME, "TimeToShow", 2000);
+ options.fisteps = DBGetContactSettingDword(NULL, MODNAME, "FadeinSpeed", 5);
+ options.fosteps = DBGetContactSettingDword(NULL, MODNAME, "FadeoutSpeed", 5);
+ options.inheritGS = DBGetContactSettingByte(NULL, MODNAME, "InheritGlobalSound", 1);
+ options.showversion = DBGetContactSettingByte(NULL, MODNAME, "ShowVersion", 0);
+ options.random = DBGetContactSettingByte(NULL, MODNAME, "Random", 0);
+ options.runonce = DBGetContactSettingByte(NULL, MODNAME, "DisableAfterStartup", 0);
+}
+
+BOOL Exists(LPCTSTR strName)
+{
+ return GetFileAttributes(strName) != INVALID_FILE_ATTRIBUTES;
+}
+
+INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+ if (!png2dibavail)
+ {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PNG2DIBWARN), SW_SHOW);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ACTIVE), false);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_RANDOM), false);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SPLASHPATH), false);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHOOSESPLASH), false);
+ }
+ ReadIniConfig();
+ TCHAR inBuf[80];
+ DBVARIANT dbv = {0};
+ DBGetContactSettingTString(NULL, MODNAME, "Path", &dbv);
+ if (lstrcmp(dbv.ptszVal, NULL) == 0)
+ {
+ _tcscpy_s(inBuf, _T("splash\\splash.png"));
+ DBFreeVariant(&dbv);
+ }
+ else
+ _tcscpy_s(inBuf, dbv.ptszVal);
+ dbv.ptszVal = NULL;
+ SetWindowText(GetDlgItem(hwndDlg, IDC_SPLASHPATH),inBuf);
+ DBGetContactSettingTString(NULL, MODNAME, "Sound", &dbv);
+ if (lstrcmp(dbv.ptszVal, NULL) == 0)
+ {
+ _tcscpy_s(inBuf, _T("sounds\\startup.wav"));
+ DBFreeVariant(&dbv);
+ }
+ else
+ _tcscpy_s(inBuf, dbv.ptszVal);
+ dbv.ptszVal = NULL;
+ SetWindowText(GetDlgItem(hwndDlg, IDC_SNDPATH),inBuf);
+ DBGetContactSettingTString(NULL, MODNAME, "VersionPrefix", &dbv);
+ if (lstrcmp(dbv.ptszVal, NULL) == 0)
+ {
+ _tcscpy_s(inBuf, _T(""));
+ DBFreeVariant(&dbv);
+ }
+ else
+ _tcscpy_s(inBuf, dbv.ptszVal);
+ dbv.ptszVal = NULL;
+ SetWindowText(GetDlgItem(hwndDlg, IDC_VERSIONPREFIX), inBuf);
+ if (options.active) CheckDlgButton(hwndDlg, IDC_ACTIVE, BST_CHECKED);
+ if (options.playsnd && !options.inheritGS) CheckDlgButton(hwndDlg, IDC_PLAYSND, BST_INDETERMINATE);
+ else if (options.playsnd) CheckDlgButton(hwndDlg, IDC_PLAYSND, BST_CHECKED);
+ //if (options.loopsnd) CheckDlgButton(hwndDlg, IDC_LOOPSOUND, BST_CHECKED);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_LOOPSOUND), false);
+ if (options.fadein) CheckDlgButton(hwndDlg, IDC_FADEIN, BST_CHECKED);
+ if (options.fadeout) CheckDlgButton(hwndDlg, IDC_FADEOUT, BST_CHECKED);
+ if (options.random) CheckDlgButton(hwndDlg, IDC_RANDOM, BST_CHECKED);
+ if (options.showversion) CheckDlgButton(hwndDlg, IDC_SHOWVERSION, BST_CHECKED);
+
+ SetWindowText(GetDlgItem(hwndDlg, IDC_SHOWTIME), _itot(options.showtime, inBuf, 10));
+ SetWindowText(GetDlgItem(hwndDlg, IDC_FISTEP), _itot(options.fisteps, inBuf, 10));
+ SetWindowText(GetDlgItem(hwndDlg, IDC_FOSTEP), _itot(options.fosteps, inBuf, 10));
+
+ SendDlgItemMessage(hwndDlg, IDC_SHOWTIME, EM_LIMITTEXT, 5, 0);
+ /*
+ SendDlgItemMessage(hwndDlg, IDC_ST_SPIN, UDM_SETRANGE32, 0, 20000);
+ SendDlgItemMessage(hwndDlg, IDC_FI_SPIN, UDM_SETRANGE32, 1, 7);
+ SendDlgItemMessage(hwndDlg, IDC_FO_SPIN, UDM_SETRANGE32, 1, 7);
+ */
+
+ return TRUE;
+ }
+
+ case WM_COMMAND:
+ {
+ switch(LOWORD(wParam))
+ {
+ case IDC_PREVIEW:
+ {
+ ShowSplash(true);
+ break;
+ }
+
+ case IDC_ACTIVE:
+ case IDC_PLAYSND:
+ case IDC_LOOPSOUND:
+ case IDC_FADEIN:
+ case IDC_FADEOUT:
+ case IDC_SHOWTIME:
+ case IDC_RANDOM:
+ case IDC_SHOWVERSION:
+ case IDC_FISTEP:
+ case IDC_FOSTEP:
+ {
+ if (IsDlgButtonChecked(hwndDlg, IDC_FADEIN))
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FISTEP), true);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FI_SPIN), true);
+ }
+ else
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FISTEP), false);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FI_SPIN), false);
+ }
+ if (IsDlgButtonChecked(hwndDlg, IDC_FADEOUT))
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FOSTEP), true);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FO_SPIN), true);
+ }
+ else
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FOSTEP), false);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FO_SPIN), false);
+ }
+
+ if ((HWND)lParam != GetFocus())
+ return 0;
+ else {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ }
+ break;
+ }
+
+ case IDC_CHOOSESPLASH:
+ {
+ TCHAR szTempPath[MAX_PATH], initDir[MAX_PATH];
+ TCHAR *pos;
+
+ if (Exists(szSplashFile))
+ {
+ lstrcpy(initDir, szSplashFile);
+ pos = _tcsrchr(initDir, _T('\\'));
+ if(pos != NULL) *pos = 0;
+ }
+ else
+ {
+ szMirDir = Utils_ReplaceVarsT(_T("%miranda_path%"));
+ lstrcpy(initDir, szMirDir);
+ mir_free(szMirDir);
+ }
+
+ OPENFILENAME ofn = {0};
+ ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+ TCHAR tmp[MAX_PATH];
+ mir_sntprintf(tmp, SIZEOF(tmp), _T("%s (*.png, *.bmp)%c*.png;*.bmp%c%c"), TranslateT("Graphic files"), 0, 0, 0);
+ ofn.lpstrFilter = tmp;
+ ofn.hwndOwner = 0;
+ ofn.lpstrFile = szTempPath;
+ ofn.nMaxFile = MAX_PATH;
+ ofn.nMaxFileTitle = MAX_PATH;
+ ofn.Flags = OFN_HIDEREADONLY;
+ ofn.lpstrInitialDir = initDir;
+ *szTempPath = '\0';
+ ofn.lpstrDefExt = _T("");
+
+ if (GetOpenFileName(&ofn))
+ {
+ lstrcpy(szSplashFile, szTempPath);
+
+ #ifdef _DEBUG
+ logMessage(_T("Set path"), szSplashFile);
+ #endif
+
+ // Make path relative
+ int result = CallService(MS_UTILS_PATHTORELATIVET, (WPARAM)szTempPath, (LPARAM)szPath2Spash);
+
+ if(result && lstrlen(szPath2Spash) > 0)
+ {
+ if (options.random)
+ {
+ TCHAR *pos;
+ pos = _tcsrchr(szPath2Spash, _T('\\'));
+ if (pos != NULL)
+ {
+ *pos = 0;
+ lstrcat(szPath2Spash, _T("\\"));
+ }
+ }
+
+ SetWindowText(GetDlgItem(hwndDlg, IDC_SPLASHPATH), szPath2Spash);
+ }
+
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+
+ break;
+ }
+
+ case IDC_CHOOSESND:
+ {
+ TCHAR szTempPath[MAX_PATH], initDir[MAX_PATH];
+ TCHAR *pos;
+
+ if (Exists(szSoundFile))
+ {
+ lstrcpy(initDir, szSoundFile);
+ pos = _tcsrchr(initDir, _T('\\'));
+ if(pos != NULL) *pos = 0;
+ }
+ else
+ {
+ szMirDir = Utils_ReplaceVarsT(_T("%miranda_path%"));
+ lstrcpy(initDir, szMirDir);
+ mir_free(szMirDir);
+ }
+
+ OPENFILENAME ofn = {0};
+ ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+ TCHAR tmp[MAX_PATH];
+ mir_sntprintf(tmp, SIZEOF(tmp), _T("%s (*.wav, *.mp3)%c*.wav;*.mp3%c%c"), TranslateT("Sound Files"), 0, 0, 0);
+ ofn.lpstrFilter = tmp;
+ ofn.hwndOwner = 0;
+ ofn.lpstrFile = szTempPath;
+ ofn.nMaxFile = MAX_PATH;
+ ofn.nMaxFileTitle = MAX_PATH;
+ ofn.Flags = OFN_HIDEREADONLY;
+ ofn.lpstrInitialDir = initDir;
+ *szTempPath = '\0';
+ ofn.lpstrDefExt = _T("");
+
+ if (GetOpenFileName(&ofn))
+ {
+ lstrcpy(szSoundFile,szTempPath);
+
+ #ifdef _DEBUG
+ logMessage(_T("Set sound path"), szSoundFile);
+ #endif
+
+ // Make path relative
+ int result = CallService(MS_UTILS_PATHTORELATIVET, (WPARAM)szTempPath, (LPARAM)szSoundFilePath);
+
+ if(result && lstrlen(szSoundFile) > 0)
+ SetWindowText(GetDlgItem(hwndDlg, IDC_SNDPATH),szSoundFilePath);
+
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+
+ break;
+ }
+ }
+
+ default:
+ {
+ if (HIWORD(wParam) != EN_CHANGE || (HWND) lParam != GetFocus())
+ return 0;
+ else
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ break;
+ }
+
+ case WM_NOTIFY:
+ {
+ if (((LPNMHDR)lParam)->idFrom == 0)
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case PSN_APPLY:
+ {
+ TCHAR tmp[MAX_PATH];
+
+ GetWindowText(GetDlgItem(hwndDlg, IDC_SPLASHPATH), tmp, MAX_PATH);
+ DBWriteContactSettingTString(NULL, MODNAME, "Path", tmp);
+
+ 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);
+
+ GetWindowText(GetDlgItem(hwndDlg, IDC_SHOWTIME), tmp, MAX_PATH);
+ DBWriteContactSettingDword(NULL, MODNAME, "TimeToShow", _ttoi(tmp));
+ options.showtime = _ttoi(tmp);
+
+ GetWindowText(GetDlgItem(hwndDlg, IDC_FISTEP), tmp, MAX_PATH);
+ DBWriteContactSettingDword(NULL, MODNAME, "FadeinSpeed", _ttoi(tmp));
+ options.fisteps = _ttoi(tmp);
+
+ GetWindowText(GetDlgItem(hwndDlg, IDC_FOSTEP), tmp, MAX_PATH);
+ DBWriteContactSettingDword(NULL, MODNAME, "FadeoutSpeed", _ttoi(tmp));
+ options.fosteps = _ttoi(tmp);
+
+ if (IsDlgButtonChecked(hwndDlg, IDC_ACTIVE))
+ {
+ DBWriteContactSettingByte(NULL, MODNAME, "Active", 1);
+ options.active = 1;
+ }
+ else
+ {
+ DBWriteContactSettingByte(NULL, MODNAME, "Active", 0);
+ options.active = 0;
+ }
+
+ if (IsDlgButtonChecked(hwndDlg, IDC_PLAYSND))
+ {
+ DBWriteContactSettingByte(NULL, MODNAME, "PlaySound", 1);
+ options.playsnd = 1;
+ DBWriteContactSettingByte(NULL, MODNAME, "InheritGlobalSound", 1);
+ options.inheritGS = 1;
+ }
+ else
+ {
+ DBWriteContactSettingByte(NULL, MODNAME, "PlaySound", 0);
+ options.playsnd = 0;
+ DBWriteContactSettingByte(NULL, MODNAME, "InheritGlobalSound", 0);
+ options.inheritGS = 0;
+ }
+
+ if (IsDlgButtonChecked(hwndDlg, IDC_PLAYSND) == BST_INDETERMINATE)
+ {
+ DBWriteContactSettingByte(NULL, MODNAME, "PlaySound", 1);
+ options.playsnd = 1;
+ DBWriteContactSettingByte(NULL, MODNAME, "InheritGlobalSound", 0);
+ options.inheritGS = 0;
+ }
+
+ /*
+ if (IsDlgButtonChecked(hwndDlg, IDC_LOOPSOUND))
+ {
+ WritePrivateProfileString("Splash","LoopSound","1",szIniFile);
+ options.loopsnd = 1;
+ }
+ else
+ {
+ WritePrivateProfileString("Splash","LoopSound","0",szIniFile);
+ options.loopsnd = 0;
+ }
+ */
+
+ if (IsDlgButtonChecked(hwndDlg, IDC_FADEIN))
+ {
+ DBWriteContactSettingByte(NULL, MODNAME, "FadeIn", 1);
+ options.fadein = 1;
+ }
+ else
+ {
+ DBWriteContactSettingByte(NULL, MODNAME, "FadeIn", 0);
+ options.fadein = 0;
+ }
+ if (IsDlgButtonChecked(hwndDlg, IDC_FADEOUT))
+ {
+ DBWriteContactSettingByte(NULL, MODNAME, "FadeOut", 1);
+ options.fadeout = 1;
+ }
+ else
+ {
+ DBWriteContactSettingByte(NULL, MODNAME, "FadeOut", 0);
+ options.fadeout = 0;
+ }
+ if (IsDlgButtonChecked(hwndDlg, IDC_RANDOM))
+ {
+ DBWriteContactSettingByte(NULL, MODNAME, "Random", 1);
+ options.random = 1;
+ }
+ else
+ {
+ DBWriteContactSettingByte(NULL, MODNAME, "Random", 0);
+ options.random = 0;
+ }
+ if (IsDlgButtonChecked(hwndDlg, IDC_SHOWVERSION))
+ {
+ DBWriteContactSettingByte(NULL, MODNAME, "ShowVersion", 1);
+ options.showversion = 1;
+ }
+ else
+ {
+ DBWriteContactSettingByte(NULL, MODNAME, "ShowVersion", 0);
+ options.showversion = 0;
+ }
+ return TRUE;
+ }
+ }
+ }
+
+ case WM_DESTROY:
+ break;
+ }
+ return FALSE;
+}
+
+int OptInit(WPARAM wParam, LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp;
+
+ ZeroMemory(&odp, sizeof(odp));
+ odp.cbSize = sizeof(odp);
+ odp.position = 0;
+ odp.hInstance = hInst;
+ odp.ptszGroup = _T("Skins");
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_SPLASH_OPT);
+ odp.ptszTitle = _T("Splash Screen");
+ odp.pfnDlgProc = DlgProcOptions;
+ odp.flags = ODPF_TCHAR | ODPF_BOLDGROUPS;
+ CallService(MS_OPT_ADDPAGE, wParam, (LPARAM) &odp);
+ return 0;
+}
diff --git a/plugins/SplashScreen/src/resource.h b/plugins/SplashScreen/src/resource.h
new file mode 100644
index 0000000000..94480d0ce5
--- /dev/null
+++ b/plugins/SplashScreen/src/resource.h
@@ -0,0 +1,36 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by splash.rc
+//
+#define IDD_SPLASH_OPT 102
+#define IDC_CHOOSESPLASH 1004
+#define IDC_SPLASHPATH 1005
+#define IDC_PREVIEW 1006
+#define IDC_ACTIVE 1007
+#define IDC_SNDPATH 1008
+#define IDC_FADEIN 1009
+#define IDC_FADEOUT 1010
+#define IDC_CHOOSESND 1011
+#define IDC_PLAYSND 1012
+#define IDC_SHOWTIME 1013
+#define IDC_ST_SPIN 1014
+#define IDC_FISTEP 1015
+#define IDC_FI_SPIN 1016
+#define IDC_FOSTEP 1017
+#define IDC_FO_SPIN 1018
+#define IDC_RANDOM 1019
+#define IDC_LOOPSOUND 1022
+#define IDC_SHOWVERSION 1023
+#define IDC_VERSIONPREFIX 1024
+#define IDC_PNG2DIBWARN 1025
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 104
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1026
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/plugins/SplashScreen/src/services.cpp b/plugins/SplashScreen/src/services.cpp
new file mode 100644
index 0000000000..7d4730c8f3
--- /dev/null
+++ b/plugins/SplashScreen/src/services.cpp
@@ -0,0 +1,74 @@
+/*
+ Splash Screen Plugin for Miranda-IM (www.miranda-im.org)
+ (c) 2004-2007 nullbie, (c) 2005-2007 Thief
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ File name : $URL: http://svn.miranda.im/mainrepo/splashscreen/trunk/src/services.cpp $
+ Revision : $Rev: 951 $
+ Last change on : $Date: 2007-10-16 18:46:53 +0400 (Вт, 16 окт 2007) $
+ Last change by : $Author: Thief $
+
+*/
+
+#include "headers.h"
+
+INT_PTR ShowSplashService(WPARAM wparam,LPARAM lparam)
+{
+ bserviceinvoked = true;
+ TCHAR szOldfn [256];
+ TCHAR* pos;
+ TCHAR* filename = (TCHAR*) wparam;
+ int timetoshow = (int) lparam;
+
+ lstrcpy(szOldfn, szSplashFile);
+ options.showtime = timetoshow;
+
+ pos = _tcsrchr(filename, _T(':'));
+ if (pos == NULL)
+ mir_sntprintf(szSplashFile, SIZEOF(szSplashFile), _T("%s\\%s"), szMirDir, filename);
+ else
+ lstrcpy(szSplashFile, filename);
+
+ ShowSplash(false);
+
+ lstrcpy(szSplashFile, szOldfn);
+
+ return 0;
+}
+
+#ifdef _DEBUG
+INT_PTR TestService(WPARAM wParam,LPARAM lParam)
+{
+ TCHAR szTempPath[MAX_PATH];
+
+ OPENFILENAME ofn={0};
+ ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+ ofn.lpstrFilter = _T("PNG and BMP files\0*.png;*.bmp\0\0");
+ ofn.hwndOwner=0;
+ ofn.lpstrFile = szTempPath;
+ ofn.nMaxFile = MAX_PATH;
+ ofn.nMaxFileTitle = MAX_PATH;
+ ofn.Flags = OFN_HIDEREADONLY;
+ ofn.lpstrInitialDir = szSplashFile;
+ *szTempPath = '\0';
+ ofn.lpstrDefExt = _T("");
+
+ if (GetOpenFileName(&ofn))
+ CallService(MS_SHOWSPLASH,(WPARAM)szTempPath,(LPARAM)0);
+
+ return 0;
+}
+#endif \ No newline at end of file
diff --git a/plugins/SplashScreen/src/splash.cpp b/plugins/SplashScreen/src/splash.cpp
new file mode 100644
index 0000000000..05df53d142
--- /dev/null
+++ b/plugins/SplashScreen/src/splash.cpp
@@ -0,0 +1,434 @@
+/*
+Splash Screen Plugin for Miranda-IM (www.miranda-im.org)
+(c) 2004-2007 nullbie, (c) 2005-2007 Thief
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+File name : $URL: http://svn.miranda.im/mainrepo/splashscreen/trunk/src/splash.cpp $
+Revision : $Rev: 1585 $
+Last change on : $Date: 2010-04-09 13:13:29 +0400 (Пт, 09 апр 2010) $
+Last change by : $Author: ghazan $
+
+*/
+
+#include "headers.h"
+
+BOOL bpreviewruns;
+MyBitmap *SplashBmp, *tmpBmp;
+
+LRESULT CALLBACK SplashWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch (message)
+ {
+ case WM_LOADED:
+ {
+ #ifdef _DEBUG
+ logMessage(_T("WM_LOADED"), _T("called"));
+ #endif
+
+ if (!MyUpdateLayeredWindow) ShowWindow(hwndSplash, SW_SHOWNORMAL);
+ if (!options.showtime) SetTimer(hwnd, 7, 2000, 0);
+
+ break;
+ }
+
+ case WM_LBUTTONDOWN:
+ PostMessage(hwnd, WM_CLOSE, 0, 0);
+ break;
+
+ case WM_TIMER:
+
+ #ifdef _DEBUG
+ TCHAR b [40];
+ mir_sntprintf(b, SIZEOF(b), _T("%d"), wParam);
+ logMessage(_T("Timer ID"), b);
+ mir_sntprintf(b, SIZEOF(b), _T("%d"), options.showtime);
+ logMessage(_T("ShowTime value"), b);
+ #endif
+
+ if (options.showtime > 0) //TimeToShow enabled
+ {
+ if (wParam == 6)
+ {
+ PostMessage(hwnd, WM_CLOSE, 0, 0);
+ #ifdef _DEBUG
+ logMessage(_T("Showtime timer"), _T("triggered"));
+ #endif
+ }
+ }
+ else
+ {
+ PostMessage(hwnd, WM_CLOSE, 0, 0);
+ if (wParam == 7)
+ {
+ #ifdef _DEBUG
+ logMessage(_T("On Modules Loaded timer"), _T("triggered"));
+ #endif
+ }
+ if (wParam == 8)
+ {
+ #ifdef _DEBUG
+ logMessage(_T("On Modules Loaded workaround"), _T("triggered"));
+ #endif
+ }
+ }
+
+ break;
+
+ case WM_RBUTTONDOWN:
+ {
+ ShowWindow(hwndSplash, SW_HIDE);
+ DestroyWindow(hwndSplash);
+ bpreviewruns = false; // preview is stopped.
+ break;
+ }
+
+ case WM_CLOSE:
+ {
+ if (MyUpdateLayeredWindow) // Win 2000+
+ {
+ RECT rc; GetWindowRect(hwndSplash, &rc);
+ POINT ptDst = { rc.left, rc.top };
+ POINT ptSrc = { 0, 0 };
+ SIZE sz = { rc.right - rc.left, rc.bottom - rc.top };
+
+ BLENDFUNCTION blend;
+ blend.BlendOp = AC_SRC_OVER;
+ blend.BlendFlags = 0;
+ blend.SourceConstantAlpha = 255;
+ blend.AlphaFormat = AC_SRC_ALPHA;
+
+ // Fade Out
+ if (options.fadeout)
+ {
+ int i;
+ for (i = 255; i>=0; i -= options.fosteps)
+ {
+ blend.SourceConstantAlpha = i;
+ MyUpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA);
+ Sleep(1);
+ }
+ }
+ }
+ if (bserviceinvoked) bserviceinvoked = false;
+ if (bpreviewruns) bpreviewruns = false;
+
+ DestroyWindow(hwndSplash);
+ }
+
+ case WM_MOUSEMOVE:
+ {
+ if (bserviceinvoked)
+ PostMessage(hwnd, WM_CLOSE, 0, 0);
+ break;
+ }
+
+ case WM_DESTROY:
+ {
+ PostQuitMessage(0);
+ #ifdef _DEBUG
+ logMessage(_T("WM_DESTROY"), _T("called"));
+ #endif
+ break;
+ }
+
+ 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);
+ }
+ break;
+ }
+
+ ShowWindow(hwndSplash, SW_HIDE);
+ DestroyWindow(hwndSplash);
+ break;
+ }
+
+ return DefWindowProc(hwnd, message, wParam, lParam);
+}
+
+int SplashThread(void *arg)
+{
+ // Old code, doesn't support mp3 files
+ //if (options.playsnd) PlaySound(szSoundFile, NULL, SND_ASYNC | SND_FILENAME | SND_NOWAIT);
+ if (options.playsnd)
+ {
+ TCHAR cmd[MAX_PATH];
+ 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;
+ wcl.cbSize = sizeof(wcl);
+ wcl.lpfnWndProc = SplashWindowProc;
+ wcl.style = 0;
+ wcl.cbClsExtra = 0;
+ wcl.cbWndExtra = 0;
+ wcl.hInstance = hInst;
+ wcl.hIcon = NULL;
+ wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wcl.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
+ wcl.lpszMenuName = NULL;
+ wcl.lpszClassName = _T(SPLASH_CLASS);
+ wcl.hIconSm = NULL;
+ RegisterClassEx(&wcl);
+
+ RECT DesktopRect;
+ int w = GetSystemMetrics(SM_CXSCREEN);
+ int h = GetSystemMetrics(SM_CYSCREEN);
+ DesktopRect.left = 0;
+ DesktopRect.top = 0;
+ DesktopRect.right = w;
+ DesktopRect.bottom = h;
+
+ RECT WindowRect;
+ WindowRect.left = (DesktopRect.left + DesktopRect.right - SplashBmp->getWidth()) / 2;
+ WindowRect.top = (DesktopRect.top + DesktopRect.bottom - SplashBmp->getHeight()) / 2;
+ WindowRect.right = WindowRect.left + SplashBmp->getWidth();
+ WindowRect.bottom = WindowRect.top + SplashBmp->getHeight();
+
+ hwndSplash = CreateWindowEx(
+ WS_EX_TOOLWINDOW | WS_EX_TOPMOST,//dwStyleEx
+ _T(SPLASH_CLASS), //Class name
+ NULL, //Title
+ DS_SETFONT | DS_FIXEDSYS | WS_POPUP, //dwStyle
+ WindowRect.left, // x
+ WindowRect.top, // y
+ SplashBmp->getWidth(), // Width
+ SplashBmp->getHeight(), // Height
+ HWND_DESKTOP, //Parent
+ NULL, //menu handle
+ hInst, //Instance
+ NULL);
+
+ RECT rc; GetWindowRect(hwndSplash, &rc);
+ POINT ptDst = {rc.left, rc.top};
+ POINT ptSrc = {0, 0};
+ SIZE sz = {rc.right - rc.left, rc.bottom - rc.top};
+ bool splashWithMarkers = false;
+
+ BLENDFUNCTION blend;
+ blend.BlendOp = AC_SRC_OVER;
+ blend.BlendFlags = 0;
+ blend.SourceConstantAlpha = 0;
+ blend.AlphaFormat = AC_SRC_ALPHA;
+
+ if (options.showversion)
+ {
+ // locate text markers:
+ int i, x = -1, y = -1;
+
+ 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 (MyUpdateLayeredWindow) // Win 2000+
+ {
+ SetWindowLongPtr(hwndSplash, GWL_EXSTYLE, GetWindowLongPtr(hwndSplash, GWL_EXSTYLE) | WS_EX_LAYERED);
+ /*
+ if (splashWithMarkers)
+ {
+ ++ptSrc.x;
+ ++ptSrc.y;
+ }
+ */
+ MyUpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA);
+
+ ShowWindow(hwndSplash, SW_SHOWNORMAL);
+ }
+ else // Win 9x
+ {
+ tmpBmp = new MyBitmap(SplashBmp->getWidth(),SplashBmp->getHeight());
+ HDC dtDC = GetDC(GetDesktopWindow());
+
+ BitBlt(tmpBmp->getDC(),
+ 0,
+ 0,
+ SplashBmp->getWidth(),
+ SplashBmp->getHeight(),
+ dtDC,
+ (DesktopRect.left + DesktopRect.right - SplashBmp->getWidth()) / 2,
+ (DesktopRect.top + DesktopRect.bottom - SplashBmp->getHeight()) / 2,
+ SRCCOPY);
+
+ ReleaseDC(GetDesktopWindow(), dtDC);
+
+ tmpBmp->Blend(SplashBmp, (splashWithMarkers?-1:0), (splashWithMarkers?-1:0), SplashBmp->getWidth(), SplashBmp->getHeight());
+
+ }
+
+ if (MyUpdateLayeredWindow) // Win 2000+
+ {
+ if (options.fadein)
+ {
+ // Fade in
+ int i;
+ for (i = 0; i < 255; i += options.fisteps)
+ {
+ 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);
+ }
+
+ if (DWORD(arg) > 0)
+ {
+ if (SetTimer(hwndSplash, 6, DWORD(arg), 0))
+ {
+ #ifdef _DEBUG
+ logMessage(_T("Timer TimeToShow"), _T("set"));
+ #endif
+ }
+ }
+ else
+ if (bmodulesloaded)
+ {
+ if (SetTimer(hwndSplash, 8, 2000, 0))
+ {
+ #ifdef _DEBUG
+ logMessage(_T("Timer Modules loaded"), _T("set"));
+ #endif
+ }
+ }
+
+ // 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)
+ mciSendString(_T("close song1"), NULL, 0, 0);
+
+ ExitThread(0);
+ return 1;
+}
+
+BOOL ShowSplash(BOOL bpreview)
+{
+ if (bpreview && bpreviewruns) return 0;
+
+ if (bpreview) bpreviewruns = true;
+ unsigned long timeout = 0;
+
+ SplashBmp = new MyBitmap;
+
+ #ifdef _DEBUG
+ logMessage(_T("Loading splash file"), szSplashFile);
+ #endif
+
+ SplashBmp->loadFromFile(szSplashFile, NULL);
+
+ DWORD threadID;
+
+ #ifdef _DEBUG
+ logMessage(_T("Thread"), _T("start"));
+ #endif
+
+ if (bpreview)
+ {
+ ShowWindow(hwndSplash, SW_HIDE);
+ DestroyWindow(hwndSplash);
+
+ timeout = 2000;
+ #ifdef _DEBUG
+ logMessage(_T("Preview"), _T("yes"));
+ #endif
+ }
+ else
+ {
+ timeout = options.showtime;
+ #ifdef _DEBUG
+ TCHAR b [40];
+ mir_sntprintf(b, SIZEOF(b), _T("%d"), options.showtime);
+ logMessage(_T("Timeout"), b);
+ #endif
+ }
+
+ hSplashThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)SplashThread, (LPVOID)timeout, 0, &threadID);
+
+ #ifdef _DEBUG
+ logMessage(_T("Thread"), _T("end"));
+ #endif
+
+ CloseHandle(hSplashThread);
+ hSplashThread = NULL;
+
+ return 1;
+} \ No newline at end of file
diff --git a/plugins/SplashScreen/src/splash.rc b/plugins/SplashScreen/src/splash.rc
new file mode 100644
index 0000000000..b71eb0a2fd
--- /dev/null
+++ b/plugins/SplashScreen/src/splash.rc
@@ -0,0 +1,152 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// Neutral resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
+#ifdef _WIN32
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+#pragma code_page(1251)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO MOVEABLE PURE
+BEGIN
+ IDD_SPLASH_OPT, DIALOG
+ BEGIN
+ RIGHTMARGIN, 307
+ VERTGUIDE, 32
+ VERTGUIDE, 39
+ VERTGUIDE, 58
+ VERTGUIDE, 101
+ VERTGUIDE, 130
+ VERTGUIDE, 172
+ HORZGUIDE, 119
+ HORZGUIDE, 136
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_SPLASH_OPT DIALOGEX 0, 0, 314, 240
+STYLE DS_FIXEDSYS | WS_CHILD
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg"
+BEGIN
+ GROUPBOX "Splash Options",IDC_STATIC,20,7,275,81
+ CONTROL "Show splash",IDC_ACTIVE,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,58,26,64,10
+ CONTROL "Show random splash",IDC_RANDOM,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,130,26,163,10
+ EDITTEXT IDC_SPLASHPATH,69,39,145,13,ES_AUTOHSCROLL
+ PUSHBUTTON "...",IDC_CHOOSESPLASH,222,40,22,11
+ CONTROL "Play sound",IDC_PLAYSND,"Button",BS_AUTO3STATE |
+ WS_TABSTOP,58,55,64,10
+ CONTROL "Loop sound",IDC_LOOPSOUND,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,130,55,137,10
+ EDITTEXT IDC_SNDPATH,69,67,145,13,ES_AUTOHSCROLL
+ PUSHBUTTON "...",IDC_CHOOSESND,222,68,22,11
+ GROUPBOX "Show Miranda Version",IDC_STATIC,20,90,275,42
+ CONTROL "Enable",IDC_SHOWVERSION,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,39,109,63,8
+ LTEXT "Prefix:",IDC_STATIC,130,108,42,10
+ EDITTEXT IDC_VERSIONPREFIX,180,106,85,13,ES_AUTOHSCROLL
+ GROUPBOX "Appearance",IDC_STATIC,20,135,275,72
+ LTEXT "Display time:",IDC_STATIC,40,150,77,8
+ EDITTEXT IDC_SHOWTIME,130,149,39,12,ES_AUTOHSCROLL | ES_NUMBER
+ CONTROL "",IDC_ST_SPIN,"msctls_updown32",UDS_SETBUDDYINT |
+ UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS |
+ UDS_NOTHOUSANDS,171,149,10,10
+ LTEXT "msec",IDC_STATIC,175,150,95,9
+ CONTROL "Fade in:",IDC_FADEIN,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,39,169,80,8
+ EDITTEXT IDC_FISTEP,130,168,39,12,ES_AUTOHSCROLL
+ CONTROL "",IDC_FI_SPIN,"msctls_updown32",UDS_SETBUDDYINT |
+ UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,170,167,
+ 10,10
+ LTEXT "steps",IDC_STATIC,176,169,95,9
+ CONTROL "Fade out:",IDC_FADEOUT,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,39,188,82,8
+ EDITTEXT IDC_FOSTEP,130,186,39,12,ES_AUTOHSCROLL
+ CONTROL "",IDC_FO_SPIN,"msctls_updown32",UDS_SETBUDDYINT |
+ UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,173,186,
+ 10,10
+ LTEXT "steps",IDC_STATIC,176,187,95,9
+ LTEXT "Advaimg library not found. Please get it from nigtlies to be able to use images.",
+ IDC_PNG2DIBWARN,24,210,185,17,NOT WS_VISIBLE
+ PUSHBUTTON "Preview...",IDC_PREVIEW,218,211,75,19
+END
+
+#endif // Neutral resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Unknown language: 0x22, 0x1 resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_UKR)
+#ifdef _WIN32
+LANGUAGE 0x22, 0x1
+#pragma code_page(1251)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE MOVEABLE PURE
+BEGIN
+ "resource.h\0"
+END
+
+3 TEXTINCLUDE MOVEABLE PURE
+BEGIN
+ "\r\n"
+END
+
+2 TEXTINCLUDE MOVEABLE PURE
+BEGIN
+ "#include ""afxres.h""\r\n"
+END
+
+#endif // APSTUDIO_INVOKED
+
+#endif // Unknown language: 0x22, 0x1 resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/plugins/SplashScreen/src/version.h b/plugins/SplashScreen/src/version.h
new file mode 100644
index 0000000000..98d6fc3ef0
--- /dev/null
+++ b/plugins/SplashScreen/src/version.h
@@ -0,0 +1,30 @@
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 1
+#define __RELEASE_NUM 2
+#define __BUILD_NUM 3
+
+#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
+#define __FILEVERSION_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM
+
+#define __STRINGIFY_IMPL(x) #x
+#define __STRINGIFY(x) __STRINGIFY_IMPL(x)
+#define __VERSION_STRING __STRINGIFY(__FILEVERSION_DOTS)
+
+#ifdef _UNICODE
+#if defined(WIN64) || defined(_WIN64)
+ #define __PLUGIN_NAME "Splash Screen (Unicode x64)"
+#else
+ #define __PLUGIN_NAME "Splash Screen (Unicode)"
+#endif
+#else
+ #define __PLUGIN_NAME "Splash Screen"
+#endif
+#define __INTERNAL_NAME "AdvSplashScreen"
+#define __FILENAME "AdvSplashScreen.dll"
+#define __DESCRIPTION "Shows a splash at Miranda startup."
+#define __AUTHOR "nullbie, Thief"
+#define __AUTHOREMAIL "thief@miranda.im"
+#define __AUTHORWEB "http://addons.miranda-im.org/details.php?id=2624"
+#define __COPYRIGHT "© 2004-2007 Victor Pavlychko, 2005-2011 Alexander Turyak"
+/* C64CC8E0-CF03-474A-8B11-8BD4565CCF04 */
+#define MIID_SPLASHSCREEN {0xc64cc8e0, 0xcf03, 0x474a, {0x8b, 0x11, 0x8b, 0xd4, 0x56, 0x5c, 0xcf, 0x04}}
diff --git a/plugins/SplashScreen/src/version.rc b/plugins/SplashScreen/src/version.rc
new file mode 100644
index 0000000000..e637f0cb33
--- /dev/null
+++ b/plugins/SplashScreen/src/version.rc
@@ -0,0 +1,38 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "afxres.h"
+#include "version.h"
+
+#ifdef _WIN32
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+#endif //_WIN32
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION __FILEVERSION_STRING
+ PRODUCTVERSION __FILEVERSION_STRING
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x0L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "000004b0"
+ BEGIN
+ VALUE "FileDescription", __DESCRIPTION
+ VALUE "InternalName", __PLUGIN_NAME
+ VALUE "LegalCopyright", __COPYRIGHT
+ VALUE "OriginalFilename", __FILENAME
+ VALUE "ProductName", __PLUGIN_NAME
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x0, 1200
+ END
+END