r_text.cpp 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012
  1. /*
  2. LICENSE
  3. -------
  4. Copyright 2005 Nullsoft, Inc.
  5. All rights reserved.
  6. Redistribution and use in source and binary forms, with or without modification,
  7. are permitted provided that the following conditions are met:
  8. * Redistributions of source code must retain the above copyright notice,
  9. this list of conditions and the following disclaimer.
  10. * Redistributions in binary form must reproduce the above copyright notice,
  11. this list of conditions and the following disclaimer in the documentation
  12. and/or other materials provided with the distribution.
  13. * Neither the name of Nullsoft nor the names of its contributors may be used to
  14. endorse or promote products derived from this software without specific prior written permission.
  15. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  16. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  17. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  18. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  20. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  21. IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  22. OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. */
  24. #include <windows.h>
  25. #include <stdio.h>
  26. #include <memory.h>
  27. #include <stdlib.h>
  28. #include <math.h>
  29. #include <commctrl.h>
  30. #include "resource.h"
  31. #include "r_defs.h"
  32. #include "avs_eelif.h"
  33. #include "../Agave/Language/api_language.h"
  34. #ifndef LASER
  35. #define MOD_NAME "Render / Text"
  36. #define C_THISCLASS C_TextClass
  37. class C_THISCLASS : public C_RBASE {
  38. protected:
  39. public:
  40. C_THISCLASS();
  41. void getWord(int n, char *buf, int max);
  42. void reinit(int w, int h);
  43. float GET_FLOAT(unsigned char *data, int pos);
  44. void PUT_FLOAT(float f, unsigned char *data, int pos);
  45. void InitializeStars(int Start);
  46. void CreateStar(int A);
  47. virtual ~C_THISCLASS();
  48. virtual int render(char visdata[2][2][576], int isBeat, int *framebuffer, int *fbout, int w, int h);
  49. virtual char *get_desc() { static char desc[128]; return (!desc[0]?WASABI_API_LNGSTRING_BUF(IDS_RENDER_TEXT,desc,128):desc); }
  50. virtual HWND conf(HINSTANCE hInstance, HWND hwndParent);
  51. virtual void load_config(unsigned char *data, int len);
  52. virtual int save_config(unsigned char *data);
  53. CHOOSEFONT cf;
  54. LOGFONT lf;
  55. HBITMAP hRetBitmap;
  56. HBITMAP hOldBitmap;
  57. HFONT hOldFont;
  58. HFONT myFont;
  59. HDC hDesktopDC;
  60. HDC hBitmapDC;
  61. BITMAPINFO bi;
  62. int enabled;
  63. int color;
  64. int blend;
  65. int blendavg;
  66. int onbeat;
  67. int insertBlank;
  68. int randomPos;
  69. int valign;
  70. int halign;
  71. int onbeatSpeed;
  72. int normSpeed;
  73. char *text;
  74. int lw,lh;
  75. bool updating;
  76. int outline;
  77. int shadow;
  78. int outlinecolor;
  79. int outlinesize;
  80. int curword;
  81. int nb;
  82. int forceBeat;
  83. int xshift, yshift;
  84. int _xshift, _yshift;
  85. int forceshift;
  86. int forcealign;
  87. int _valign, _halign;
  88. int oddeven;
  89. int nf;
  90. RECT r;
  91. int *myBuffer;
  92. int forceredraw;
  93. int old_valign, old_halign, old_outline, oldshadow;
  94. int old_curword, old_clipcolor;
  95. char oldtxt[256];
  96. int old_blend1, old_blend2, old_blend3;
  97. int oldxshift, oldyshift;
  98. int randomword;
  99. int shiftinit;
  100. };
  101. static C_THISCLASS *g_ConfigThis; // global configuration dialog pointer
  102. static HINSTANCE g_hDllInstance; // global DLL instance pointer (not needed in this example, but could be useful)
  103. // Reinit bitmap buffer since size changed
  104. void C_THISCLASS::reinit(int w, int h)
  105. {
  106. // Free anything if needed
  107. if (lw || lh)
  108. {
  109. SelectObject (hBitmapDC, hOldBitmap);
  110. if (hOldFont) SelectObject(hBitmapDC, hOldFont);
  111. DeleteDC (hBitmapDC);
  112. ReleaseDC (NULL, hDesktopDC);
  113. if (myBuffer) GlobalFree(myBuffer);
  114. }
  115. // Alloc buffers, select objects, init structures
  116. myBuffer = (int *)GlobalAlloc(GMEM_FIXED,w*h*4);
  117. hDesktopDC = GetDC (NULL);
  118. hRetBitmap = CreateCompatibleBitmap (hDesktopDC, w, h);
  119. hBitmapDC = CreateCompatibleDC (hDesktopDC);
  120. hOldBitmap = (HBITMAP) SelectObject (hBitmapDC, hRetBitmap);
  121. SetTextColor(hBitmapDC, ((color & 0xFF0000) >> 16) | (color & 0xFF00) | (color&0xFF)<<16);
  122. SetBkMode(hBitmapDC, TRANSPARENT);
  123. SetBkColor(hBitmapDC, 0);
  124. if (myFont)
  125. hOldFont = (HFONT) SelectObject(hBitmapDC, myFont);
  126. else
  127. hOldFont = NULL;
  128. bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
  129. bi.bmiHeader.biWidth = w;
  130. bi.bmiHeader.biHeight = h;
  131. bi.bmiHeader.biPlanes = 1;
  132. bi.bmiHeader.biBitCount = 32;
  133. bi.bmiHeader.biCompression = BI_RGB;
  134. bi.bmiHeader.biSizeImage = 0;
  135. bi.bmiHeader.biXPelsPerMeter = 0;
  136. bi.bmiHeader.biYPelsPerMeter = 0;
  137. bi.bmiHeader.biClrUsed = 0;
  138. bi.bmiHeader.biClrImportant = 0;
  139. }
  140. C_THISCLASS::~C_THISCLASS()
  141. {
  142. // Free up everything
  143. if (lw || lh)
  144. {
  145. SelectObject (hBitmapDC, hOldBitmap);
  146. if (hOldFont) SelectObject(hBitmapDC, hOldFont);
  147. DeleteDC (hBitmapDC);
  148. ReleaseDC (NULL, hDesktopDC);
  149. if (myBuffer) GlobalFree(myBuffer);
  150. }
  151. if (text) GlobalFree(text);
  152. if (myFont)
  153. DeleteObject(myFont);
  154. }
  155. // configuration read/write
  156. C_THISCLASS::C_THISCLASS() // set up default configuration
  157. {
  158. // Init all
  159. randomword=0;
  160. shadow=0;
  161. old_valign=0;
  162. old_halign=0;
  163. old_outline=-1;
  164. old_curword=-1;
  165. old_clipcolor=-1;
  166. oldshadow=-1;
  167. *oldtxt=0;
  168. old_blend1=0;
  169. old_blend2=0;
  170. old_blend3=0;
  171. _xshift=0;
  172. _yshift=0;
  173. forceredraw=0;
  174. myBuffer = NULL;
  175. curword=0;
  176. forceshift=0;
  177. forceBeat=0;
  178. forcealign=1;
  179. xshift=0;
  180. yshift=0;
  181. outlinecolor = 0;
  182. outline=0;
  183. outline=0;
  184. color = 0xFFFFFF;
  185. enabled = 1;
  186. blend = 0;
  187. blendavg = 0;
  188. onbeat = 0;
  189. insertBlank = 0;
  190. randomPos = 0;
  191. halign = DT_CENTER;
  192. valign = DT_VCENTER;
  193. onbeatSpeed=15;
  194. normSpeed=15;
  195. myFont = NULL;
  196. memset(&cf, 0, sizeof(CHOOSEFONT));
  197. cf.lStructSize = sizeof(CHOOSEFONT);
  198. cf.lpLogFont = &lf;
  199. cf.Flags = CF_EFFECTS|CF_SCREENFONTS |CF_FORCEFONTEXIST|CF_INITTOLOGFONTSTRUCT;
  200. cf.rgbColors = color;
  201. memset(&lf, 0, sizeof(LOGFONT));
  202. text = NULL;
  203. lw=lh=0;
  204. updating=false;
  205. nb=0;
  206. outlinesize=1;
  207. oddeven=0;
  208. nf=0;
  209. shiftinit=1;
  210. }
  211. #define GET_INT() (data[pos]|(data[pos+1]<<8)|(data[pos+2]<<16)|(data[pos+3]<<24))
  212. float C_THISCLASS::GET_FLOAT(unsigned char *data, int pos)
  213. {
  214. int a = data[pos]|(data[pos+1]<<8)|(data[pos+2]<<16)|(data[pos+3]<<24);
  215. float f = *(float *)&a;
  216. return f;
  217. }
  218. void C_THISCLASS::load_config(unsigned char *data, int len) // read configuration of max length "len" from data.
  219. {
  220. int pos=0;
  221. int size;
  222. updating=true;
  223. forceredraw=1;
  224. if (len-pos >= 4) { enabled=GET_INT(); pos+=4; }
  225. if (len-pos >= 4) { color=GET_INT(); pos+=4; }
  226. if (len-pos >= 4) { blend=GET_INT(); pos+=4; }
  227. if (len-pos >= 4) { blendavg=GET_INT(); pos+=4; }
  228. if (len-pos >= 4) { onbeat=GET_INT(); pos+=4; }
  229. if (len-pos >= 4) { insertBlank=GET_INT(); pos+=4; }
  230. if (len-pos >= 4) { randomPos=GET_INT(); pos+=4; }
  231. if (len-pos >= 4) { valign=GET_INT(); pos+=4; }
  232. if (len-pos >= 4) { halign=GET_INT(); pos+=4; }
  233. if (len-pos >= 4) { onbeatSpeed=GET_INT(); pos+=4; }
  234. if (len-pos >= 4) { normSpeed=GET_INT(); pos+=4; }
  235. if (len-pos >= sizeof(cf)) { memcpy(&cf, data+pos, sizeof(cf)); pos+=sizeof(cf);}
  236. cf.lpLogFont = &lf;
  237. if (len-pos >= sizeof(lf)) { memcpy(&lf, data+pos, sizeof(lf)); pos+=sizeof(lf);}
  238. if (len-pos >= 4) { size=GET_INT(); pos+=4; }
  239. if (size > 0 && len-pos >= size)
  240. {
  241. if (text) GlobalFree(text);
  242. text = (char *)GlobalAlloc(GMEM_FIXED,size+1);
  243. memcpy(text, data+pos, size);
  244. pos+=size;
  245. }
  246. else
  247. {
  248. if (text) GlobalFree(text);
  249. text = NULL;
  250. }
  251. myFont = CreateFontIndirect(&lf);
  252. if (len-pos >= 4) { outline=GET_INT(); pos+=4; }
  253. if (len-pos >= 4) { outlinecolor=GET_INT(); pos+=4; }
  254. if (len-pos >= 4) { xshift=GET_INT(); pos+=4; }
  255. if (len-pos >= 4) { yshift=GET_INT(); pos+=4; }
  256. if (len-pos >= 4) { outlinesize=GET_INT(); pos+=4; }
  257. if (len-pos >= 4) { randomword=GET_INT(); pos+=4; }
  258. if (len-pos >= 4) { shadow=GET_INT(); pos+=4; }
  259. forcealign=1;
  260. forceredraw=1;
  261. forceshift=1;
  262. shiftinit=1;
  263. updating=false;
  264. }
  265. #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
  266. void C_THISCLASS::PUT_FLOAT(float f, unsigned char *data, int pos)
  267. {
  268. int y = *(int *)&f;
  269. data[pos]=(y)&255; data[pos+1]=(y>>8)&255; data[pos+2]=(y>>16)&255; data[pos+3]=(y>>24)&255;
  270. }
  271. extern HWND hwnd_WinampParent;
  272. int C_THISCLASS::save_config(unsigned char *data) // write configuration to data, return length. config data should not exceed 64k.
  273. {
  274. int pos=0;
  275. PUT_INT(enabled); pos+=4;
  276. PUT_INT(color); pos+=4;
  277. PUT_INT(blend); pos+=4;
  278. PUT_INT(blendavg); pos+=4;
  279. PUT_INT(onbeat); pos+=4;
  280. PUT_INT(insertBlank); pos+=4;
  281. PUT_INT(randomPos); pos+=4;
  282. PUT_INT(valign); pos+=4;
  283. PUT_INT(halign); pos+=4;
  284. PUT_INT(onbeatSpeed); pos+=4;
  285. PUT_INT(normSpeed); pos+=4;
  286. memcpy(data+pos, &cf, sizeof(cf));
  287. pos+=sizeof(cf);
  288. memcpy(data+pos, &lf, sizeof(lf));
  289. pos+=sizeof(lf);
  290. if (text)
  291. {
  292. int l=strlen(text)+1;
  293. PUT_INT(l); pos+=4;
  294. memcpy(data+pos, text, strlen(text)+1);
  295. pos+=strlen(text)+1;
  296. }
  297. else
  298. { PUT_INT(0); pos+=4;}
  299. PUT_INT(outline); pos+=4;
  300. PUT_INT(outlinecolor); pos+=4;
  301. PUT_INT(xshift); pos+=4;
  302. PUT_INT(yshift); pos+=4;
  303. PUT_INT(outlinesize); pos+=4;
  304. PUT_INT(randomword); pos+=4;
  305. PUT_INT(shadow); pos+=4;
  306. return pos;
  307. }
  308. // Parse text buffer for a specified word
  309. void C_THISCLASS::getWord(int n, char *buf, int maxlen)
  310. {
  311. int w=0;
  312. char *p=text;
  313. char *d=buf;
  314. *d=0;
  315. if (!p) return;
  316. while (w<n && *p)
  317. {
  318. if (*p==';')
  319. w++;
  320. p++;
  321. }
  322. maxlen--; // null terminator
  323. while (*p && *p != ';' && maxlen>0)
  324. {
  325. char *endp;
  326. if ((!strnicmp(p,"$(playpos",9) || !strnicmp(p,"$(playlen",9)) && (endp = strstr(p+9,")")))
  327. {
  328. char buf[128];
  329. int islen=strnicmp(p,"$(playpos",9);
  330. int add_dig=0;
  331. if (p[9]=='.')
  332. add_dig=atoi(p+10);
  333. if (add_dig > 3) add_dig=3;
  334. int pos=0;
  335. extern HWND hwnd_WinampParent;
  336. if (IsWindow(hwnd_WinampParent))
  337. {
  338. if (!SendMessageTimeout( hwnd_WinampParent, WM_USER,(WPARAM)!!islen,(LPARAM)105,SMTO_BLOCK,50,(LPDWORD)&pos))
  339. pos=0;
  340. }
  341. if (islen) pos*=1000;
  342. wsprintf(buf,"%d:%02d",pos/60000,(pos/1000)%60);
  343. if (add_dig>0)
  344. {
  345. char fmt[16];
  346. wsprintf(fmt,".%%%02dd",add_dig);
  347. int div=1;
  348. int x;
  349. for (x = 0; x < 3-add_dig; x ++)
  350. {
  351. div*=10;
  352. }
  353. wsprintf(buf+strlen(buf),fmt,(pos%1000) / div);
  354. }
  355. int l=strlen(buf);
  356. if (l > maxlen) l=maxlen;
  357. memcpy(d,buf,l);
  358. maxlen-=l;
  359. d += l;
  360. p=endp+1;
  361. }
  362. else if (!strnicmp(p,"$(title",7) && (endp = strstr(p+7,")")))
  363. {
  364. static char this_title[256];
  365. static unsigned int ltg;
  366. unsigned int now=GetTickCount();
  367. if (!this_title[0] || now-ltg > 1000 || now < ltg)
  368. {
  369. ltg=now;
  370. char *tpp;
  371. if (IsWindow(hwnd_WinampParent))
  372. {
  373. DWORD id;
  374. if (!SendMessageTimeout( hwnd_WinampParent,WM_GETTEXT,(WPARAM)sizeof(this_title),(LPARAM)this_title,SMTO_BLOCK,50,&id) || !id)
  375. {
  376. this_title[0]=0;
  377. }
  378. }
  379. tpp = this_title+strlen(this_title);
  380. while (tpp >= this_title)
  381. {
  382. char buf[9];
  383. memcpy(buf,tpp,8);
  384. buf[8]=0;
  385. if (!lstrcmpi(buf,"- Winamp")) break;
  386. tpp--;
  387. }
  388. if (tpp >= this_title) tpp--;
  389. while (tpp >= this_title && *tpp == ' ') tpp--;
  390. *++tpp=0;
  391. }
  392. int skipnum=1,max_fmtlen=0;
  393. char *titleptr=this_title;
  394. if (p[7] == ':')
  395. {
  396. char *ptr=p+8;
  397. if (*ptr == 'n') { ptr++; skipnum=0; }
  398. max_fmtlen=atoi(ptr);
  399. }
  400. // use: $(reg00), $(reg00:4.5), $(title), $(title:32), $(title:n32)
  401. if (skipnum && *titleptr >= '0' && *titleptr <= '9')
  402. {
  403. while (*titleptr >= '0' && *titleptr <= '9') titleptr++;
  404. if (*titleptr == '.')
  405. {
  406. titleptr++;
  407. if (*titleptr == ' ')
  408. {
  409. titleptr++;
  410. }
  411. else titleptr=this_title;
  412. }
  413. else titleptr=this_title;
  414. }
  415. int n=strlen(titleptr);
  416. if (n > maxlen)n=maxlen;
  417. if (max_fmtlen >0 && max_fmtlen < n) n=max_fmtlen;
  418. memcpy(d,titleptr,n);
  419. maxlen-=n;
  420. d+=n;
  421. p=endp+1;
  422. }
  423. else if (!strnicmp(p,"$(reg",5) && p[5] >= '0' && p[5] <= '9' &&
  424. p[6] >= '0' && p[6] <= '9' && (endp = strstr(p+7,")")))
  425. {
  426. char buf[128];
  427. char fmt[32];
  428. int wr=atoi(p+5);
  429. if (wr <0)wr=0;
  430. if (wr>99)wr=99;
  431. p+=7;
  432. char *fmtptr=fmt;
  433. *fmtptr++='%';
  434. if (*p == ':')
  435. {
  436. p++;
  437. while (fmtptr-fmt < 16 && ((*p >= '0' && *p <= '9') || *p == '.'))
  438. *fmtptr++=*p++;
  439. }
  440. *fmtptr++='f';
  441. *fmtptr++=0;
  442. int l=sprintf(buf,fmt,NSEEL_getglobalregs()[wr]);
  443. if (l > maxlen) l=maxlen;
  444. memcpy(d,buf,l);
  445. maxlen-=l;
  446. d += l;
  447. p = endp+1;
  448. }
  449. else
  450. {
  451. *d++=*p++;
  452. maxlen--;
  453. }
  454. }
  455. *d=0;
  456. }
  457. // Returns number of words in buffer
  458. static int getNWords(char *buf)
  459. {
  460. char *p=buf;
  461. int n=0;
  462. while (p && *p)
  463. {
  464. if (*p==';')
  465. n++;
  466. p++;
  467. }
  468. return n;
  469. }
  470. // render function
  471. // render should return 0 if it only used framebuffer, or 1 if the new output data is in fbout. this is
  472. // used when you want to do something that you'd otherwise need to make a copy of the framebuffer.
  473. // w and h are the width and height of the screen, in pixels.
  474. // isBeat is 1 if a beat has been detected.
  475. // visdata is in the format of [spectrum:0,wave:1][channel][band].
  476. int C_THISCLASS::render(char visdata[2][2][576], int isBeat, int *framebuffer, int *fbout, int w, int h)
  477. {
  478. int i,j;
  479. int *p,*d;
  480. int clipcolor;
  481. char thisText[256];
  482. if (updating) return 0;
  483. if (!enabled) return 0;
  484. if (isBeat&0x80000000) return 0;
  485. if (forcealign)
  486. {
  487. forcealign=false;
  488. _halign = halign;
  489. _valign = valign;
  490. }
  491. if (shiftinit)
  492. {
  493. shiftinit=0;
  494. _xshift = xshift;
  495. _yshift = yshift;
  496. }
  497. // If not beat sensitive and time is up for this word
  498. // OR if beat sensitive and this frame is a beat and time is up for last beat
  499. if ((!onbeat && nf >= normSpeed) || (onbeat && isBeat && !nb))
  500. { // Then choose which word to show
  501. if (!(insertBlank && !(oddeven % 2)))
  502. {
  503. if (randomword)
  504. curword=rand()%(getNWords(text)+1);
  505. else
  506. {
  507. curword++;
  508. curword%=(getNWords(text)+1);
  509. }
  510. }
  511. oddeven++;
  512. oddeven%=2;
  513. }
  514. if (forceBeat)
  515. {
  516. isBeat = 1;
  517. forceBeat=0;
  518. }
  519. // If beat sensitive and frame is a beat and last beat expired, start frame timer for this beat
  520. if (onbeat && isBeat && !nb)
  521. nb = onbeatSpeed;
  522. // Get the word(s) to show
  523. getWord(curword, thisText, 256);
  524. if (insertBlank && !oddeven)
  525. *thisText=0;
  526. // Same test as above but takes care of nb init
  527. if ((!onbeat && nf >= normSpeed) || (onbeat && isBeat && nb == onbeatSpeed))
  528. {
  529. nf=0;
  530. if (randomPos && w && h) // Handle random position
  531. {
  532. SIZE size={0,0};
  533. GetTextExtentPoint32(hBitmapDC, thisText, strlen(thisText), &size); // Don't write outside the screen
  534. _halign = DT_LEFT;
  535. if (size.cx < w)
  536. _xshift = rand() % (int)(((float)(w-size.cx) / (float)w) * 100.0F);
  537. _valign = DT_TOP;
  538. if (size.cy < h)
  539. _yshift = rand() % (int)(((float)(h-size.cy) / (float)h) * 100.0F);
  540. forceshift=1;
  541. }
  542. else
  543. { // Reset position to what is specified
  544. _halign = halign;
  545. _valign = valign;
  546. _xshift = xshift;
  547. _yshift = yshift;
  548. }
  549. }
  550. // Choose cliping color
  551. if (color != 0 && outlinecolor != 0)
  552. clipcolor = 0;
  553. else
  554. if (color != 0x000008 && outlinecolor != 0x000008)
  555. clipcolor = 8;
  556. else
  557. if (color != 0x0000010 && outlinecolor != 0x0000010)
  558. clipcolor = 10;
  559. // If size changed or if we're forced to shift the buffer
  560. if ((lw != w || lh != h) || forceshift)
  561. {
  562. if (lw != w || lh != h) // only if size changed then reinit buffer, not if its only a forcedshifting
  563. reinit(w, h);
  564. forceshift=0;
  565. forceredraw=1; // do redraw!
  566. // remember last state
  567. lw = w;
  568. lh = h;
  569. // Compute buffer position
  570. r.left = 0;
  571. r.right = w;
  572. r.top = 0;
  573. r.bottom = h;
  574. r.left += (int)((float)_xshift * (float)w / 100.0F);
  575. r.right += (int)((float)_xshift * (float)w / 100.0F);
  576. r.top += (int)((float)_yshift * (float)h / 100.0F);
  577. r.bottom += (int)((float)_yshift * (float)h / 100.0F);
  578. forceredraw=1;
  579. }
  580. // Check if we need to redraw the buffer
  581. if (forceredraw ||
  582. old_halign != _halign ||
  583. old_valign != _valign ||
  584. curword != old_curword ||
  585. (*thisText && strcmp(thisText, oldtxt)) ||
  586. old_clipcolor != clipcolor ||
  587. (old_blend1 != (blend && !(onbeat && !nb))) ||
  588. (old_blend2 != (blendavg && !(onbeat && !nb))) ||
  589. (old_blend3 != (!(onbeat && !nb))) ||
  590. old_outline != outline ||
  591. oldshadow != shadow ||
  592. _xshift != oldxshift ||
  593. _yshift != oldyshift)
  594. {
  595. forceredraw=0;
  596. old_halign = _halign;
  597. old_valign = _valign;
  598. old_curword = curword;
  599. if (thisText) strcpy(oldtxt, thisText);
  600. old_clipcolor = clipcolor;
  601. old_blend1 = (blend && !(onbeat && !nb));
  602. old_blend2 = (blendavg && !(onbeat && !nb));
  603. old_blend3 = !(onbeat && !nb);
  604. old_outline = outline;
  605. oldshadow = shadow;
  606. oldxshift = _xshift;
  607. oldyshift = _yshift;
  608. // Draw everything
  609. p = myBuffer;
  610. while (p < myBuffer+h*w) { *p = clipcolor; p++; }
  611. SetDIBits(hBitmapDC, hRetBitmap, 0, h, (void *)myBuffer, &bi, DIB_RGB_COLORS);
  612. if (*thisText)
  613. {
  614. if (outline)
  615. {
  616. SetTextColor(hBitmapDC, ((outlinecolor&0xFF0000) >> 16) | (outlinecolor& 0xFF00) | (outlinecolor&0xFF)<<16);
  617. r.left-=outlinesize; r.right-=outlinesize; r.top-=outlinesize; r.bottom-=outlinesize;
  618. DrawText(hBitmapDC, thisText, strlen(thisText), &r, _valign | _halign | DT_NOCLIP | DT_SINGLELINE);
  619. r.left+=outlinesize; r.right+=outlinesize;
  620. DrawText(hBitmapDC, thisText, strlen(thisText), &r, _valign | _halign | DT_NOCLIP | DT_SINGLELINE);
  621. r.left+=outlinesize; r.right+=outlinesize;
  622. DrawText(hBitmapDC, thisText, strlen(thisText), &r, _valign | _halign | DT_NOCLIP | DT_SINGLELINE);
  623. r.top+=outlinesize; r.bottom+=outlinesize;
  624. DrawText(hBitmapDC, thisText, strlen(thisText), &r, _valign | _halign | DT_NOCLIP | DT_SINGLELINE);
  625. r.top+=outlinesize; r.bottom+=outlinesize;
  626. DrawText(hBitmapDC, thisText, strlen(thisText), &r, _valign | _halign | DT_NOCLIP | DT_SINGLELINE);
  627. r.left-=outlinesize; r.right-=outlinesize;
  628. DrawText(hBitmapDC, thisText, strlen(thisText), &r, _valign | _halign | DT_NOCLIP | DT_SINGLELINE);
  629. r.left-=outlinesize; r.right-=outlinesize;
  630. DrawText(hBitmapDC, thisText, strlen(thisText), &r, _valign | _halign | DT_NOCLIP | DT_SINGLELINE);
  631. r.top-=outlinesize; r.bottom-=outlinesize;
  632. DrawText(hBitmapDC, thisText, strlen(thisText), &r, _valign | _halign | DT_NOCLIP | DT_SINGLELINE);
  633. r.left+=outlinesize; r.right+=outlinesize;
  634. SetTextColor(hBitmapDC, ((color&0xFF0000) >> 16) | (color& 0xFF00) | (color&0xFF)<<16);
  635. }
  636. else if (shadow)
  637. {
  638. SetTextColor(hBitmapDC, ((outlinecolor&0xFF0000) >> 16) | (outlinecolor& 0xFF00) | (outlinecolor&0xFF)<<16);
  639. r.left+=outlinesize; r.right+=outlinesize; r.top+=outlinesize; r.bottom+=outlinesize;
  640. DrawText(hBitmapDC, thisText, strlen(thisText), &r, _valign | _halign | DT_NOCLIP | DT_SINGLELINE);
  641. r.left-=outlinesize; r.right-=outlinesize; r.top-=outlinesize; r.bottom-=outlinesize;
  642. SetTextColor(hBitmapDC, ((color&0xFF0000) >> 16) | (color& 0xFF00) | (color&0xFF)<<16);
  643. }
  644. DrawText(hBitmapDC, thisText, strlen(thisText), &r, _valign | _halign | DT_NOCLIP | DT_SINGLELINE);
  645. }
  646. GetDIBits(hBitmapDC, hRetBitmap, 0, h, (void *)myBuffer, &bi, DIB_RGB_COLORS);
  647. }
  648. // Now render the bitmap text buffer over framebuffer, handle blending options.
  649. // Separate blocks here so we don4t have to make w*h tests
  650. p = myBuffer;
  651. d = framebuffer+w*(h-1);
  652. if (blend && !(onbeat && !nb))
  653. for (i=0;i<h;i++)
  654. {
  655. for (j=0;j<w;j++)
  656. {
  657. if (*p != clipcolor) *d=BLEND(*p, *d);
  658. d++;
  659. p++;
  660. }
  661. d -= w*2;
  662. }
  663. else
  664. if (blendavg && !(onbeat && !nb))
  665. for (i=0;i<h;i++)
  666. {
  667. for (j=0;j<w;j++)
  668. {
  669. if (*p != clipcolor) *d=BLEND_AVG(*p, *d);
  670. d++;
  671. p++;
  672. }
  673. d -= w*2;
  674. }
  675. else
  676. if (!(onbeat && !nb))
  677. for (i=0;i<h;i++)
  678. {
  679. for (j=0;j<w;j++)
  680. {
  681. if (*p != clipcolor)
  682. *d=*p;
  683. d++;
  684. p++;
  685. }
  686. d -= w*2;
  687. }
  688. // Advance frame counter
  689. if (!onbeat) nf++;
  690. // Decrease frametimer
  691. if (onbeat && nb) nb--;
  692. return 0;
  693. }
  694. static BOOL CALLBACK g_DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  695. {
  696. switch (uMsg)
  697. {
  698. case WM_INITDIALOG:
  699. SetDlgItemText(hwndDlg, IDC_EDIT, g_ConfigThis->text);
  700. SendDlgItemMessage(hwndDlg, IDC_SPEED, TBM_SETTICFREQ, 10, 0);
  701. SendDlgItemMessage(hwndDlg, IDC_SPEED, TBM_SETRANGE, TRUE, MAKELONG(1, 400));
  702. SendDlgItemMessage(hwndDlg, IDC_OUTLINESIZE, TBM_SETTICFREQ, 15, 0);
  703. SendDlgItemMessage(hwndDlg, IDC_OUTLINESIZE, TBM_SETRANGE, TRUE, MAKELONG(1, 16));
  704. SendDlgItemMessage(hwndDlg, IDC_OUTLINESIZE, TBM_SETPOS, TRUE, g_ConfigThis->outlinesize);
  705. SendDlgItemMessage(hwndDlg, IDC_VSHIFT, TBM_SETTICFREQ, 50, 0);
  706. SendDlgItemMessage(hwndDlg, IDC_VSHIFT, TBM_SETRANGE, TRUE, MAKELONG(0, 200));
  707. SendDlgItemMessage(hwndDlg, IDC_VSHIFT, TBM_SETPOS, TRUE, g_ConfigThis->yshift+100);
  708. SendDlgItemMessage(hwndDlg, IDC_HSHIFT, TBM_SETTICFREQ, 50, 0);
  709. SendDlgItemMessage(hwndDlg, IDC_HSHIFT, TBM_SETRANGE, TRUE, MAKELONG(0, 200));
  710. SendDlgItemMessage(hwndDlg, IDC_HSHIFT, TBM_SETPOS, TRUE, g_ConfigThis->xshift+100);
  711. if (g_ConfigThis->onbeat)
  712. SendDlgItemMessage(hwndDlg, IDC_SPEED, TBM_SETPOS, TRUE, (int)(g_ConfigThis->onbeatSpeed));
  713. else
  714. SendDlgItemMessage(hwndDlg, IDC_SPEED, TBM_SETPOS, TRUE, (int)(g_ConfigThis->normSpeed));
  715. if (g_ConfigThis->enabled) CheckDlgButton(hwndDlg,IDC_CHECK1,BST_CHECKED);
  716. if (g_ConfigThis->onbeat) CheckDlgButton(hwndDlg,IDC_ONBEAT,BST_CHECKED);
  717. if (g_ConfigThis->blend) CheckDlgButton(hwndDlg,IDC_ADDITIVE,BST_CHECKED);
  718. if (g_ConfigThis->blendavg) CheckDlgButton(hwndDlg,IDC_5050,BST_CHECKED);
  719. if (!g_ConfigThis->blend && !g_ConfigThis->blendavg)
  720. CheckDlgButton(hwndDlg,IDC_REPLACE,BST_CHECKED);
  721. if (g_ConfigThis->enabled) CheckDlgButton(hwndDlg,IDC_CHECK1,BST_CHECKED);
  722. if (g_ConfigThis->outline) CheckDlgButton(hwndDlg,IDC_OUTLINE,BST_CHECKED);
  723. if (g_ConfigThis->shadow) CheckDlgButton(hwndDlg,IDC_SHADOW,BST_CHECKED);
  724. if (!g_ConfigThis->outline && !g_ConfigThis->shadow) CheckDlgButton(hwndDlg,IDC_PLAIN,BST_CHECKED);
  725. if (g_ConfigThis->randomword) CheckDlgButton(hwndDlg,IDC_RANDWORD, BST_CHECKED);
  726. switch (g_ConfigThis->valign)
  727. {
  728. case DT_TOP:
  729. CheckDlgButton(hwndDlg,IDC_VTOP,BST_CHECKED);
  730. break;
  731. case DT_BOTTOM:
  732. CheckDlgButton(hwndDlg,IDC_VBOTTOM,BST_CHECKED);
  733. break;
  734. case DT_VCENTER:
  735. CheckDlgButton(hwndDlg,IDC_VCENTER,BST_CHECKED);
  736. break;
  737. }
  738. switch (g_ConfigThis->halign)
  739. {
  740. case DT_LEFT:
  741. CheckDlgButton(hwndDlg,IDC_HLEFT,BST_CHECKED);
  742. break;
  743. case DT_RIGHT:
  744. CheckDlgButton(hwndDlg,IDC_HRIGHT,BST_CHECKED);
  745. break;
  746. case DT_CENTER:
  747. CheckDlgButton(hwndDlg,IDC_HCENTER,BST_CHECKED);
  748. break;
  749. }
  750. if (g_ConfigThis->insertBlank) CheckDlgButton(hwndDlg,IDC_BLANKS,BST_CHECKED);
  751. if (g_ConfigThis->randomPos) {
  752. CheckDlgButton(hwndDlg,IDC_RANDOMPOS,BST_CHECKED);
  753. EnableWindow(GetDlgItem(hwndDlg, IDC_VTOP), FALSE);
  754. EnableWindow(GetDlgItem(hwndDlg, IDC_VBOTTOM), FALSE);
  755. EnableWindow(GetDlgItem(hwndDlg, IDC_VCENTER), FALSE);
  756. EnableWindow(GetDlgItem(hwndDlg, IDC_HLEFT), FALSE);
  757. EnableWindow(GetDlgItem(hwndDlg, IDC_HRIGHT), FALSE);
  758. EnableWindow(GetDlgItem(hwndDlg, IDC_HCENTER), FALSE);
  759. EnableWindow(GetDlgItem(hwndDlg, IDC_HSHIFT), FALSE);
  760. EnableWindow(GetDlgItem(hwndDlg, IDC_VSHIFT), FALSE);
  761. }
  762. return 1;
  763. case WM_NOTIFY:
  764. {
  765. if ((LOWORD(wParam) == IDC_VSHIFT) || (LOWORD(wParam) == IDC_HSHIFT))
  766. {
  767. g_ConfigThis->yshift = SendDlgItemMessage(hwndDlg, IDC_VSHIFT, TBM_GETPOS, 0, 0)-100;
  768. g_ConfigThis->xshift = SendDlgItemMessage(hwndDlg, IDC_HSHIFT, TBM_GETPOS, 0, 0)-100;
  769. g_ConfigThis->forceshift=1;
  770. g_ConfigThis->forceredraw=1;
  771. g_ConfigThis->shiftinit=1;
  772. }
  773. if (LOWORD(wParam) == IDC_OUTLINESIZE)
  774. {
  775. g_ConfigThis->outlinesize = SendDlgItemMessage(hwndDlg, IDC_OUTLINESIZE, TBM_GETPOS, 0, 0);
  776. g_ConfigThis->forceredraw=1;
  777. }
  778. if (LOWORD(wParam) == IDC_SPEED)
  779. {
  780. if (g_ConfigThis->onbeat)
  781. {
  782. g_ConfigThis->onbeatSpeed = SendDlgItemMessage(hwndDlg, IDC_SPEED, TBM_GETPOS, 0, 0);
  783. if (g_ConfigThis->nb > g_ConfigThis->onbeatSpeed)
  784. g_ConfigThis->nb = g_ConfigThis->onbeatSpeed;
  785. }
  786. else
  787. g_ConfigThis->normSpeed = SendDlgItemMessage(hwndDlg, IDC_SPEED, TBM_GETPOS, 0, 0);
  788. }
  789. return 0;
  790. }
  791. case WM_DRAWITEM:
  792. {
  793. DRAWITEMSTRUCT *di=(DRAWITEMSTRUCT *)lParam;
  794. if (di->CtlID == IDC_DEFCOL || di->CtlID == IDC_DEFOUTCOL) // paint nifty color button
  795. {
  796. GR_DrawColoredButton(di,di->CtlID == IDC_DEFCOL ? g_ConfigThis->color : g_ConfigThis->outlinecolor);
  797. }
  798. }
  799. return 0;
  800. case WM_COMMAND:
  801. if (LOWORD(wParam) == IDC_HRESET)
  802. {
  803. g_ConfigThis->xshift = 0;
  804. SendDlgItemMessage(hwndDlg, IDC_HSHIFT, TBM_SETPOS, TRUE, 100);
  805. g_ConfigThis->forceshift=1;
  806. g_ConfigThis->forceredraw=1;
  807. g_ConfigThis->shiftinit=1;
  808. }
  809. if (LOWORD(wParam) == IDC_VRESET)
  810. {
  811. g_ConfigThis->yshift = 0;
  812. SendDlgItemMessage(hwndDlg, IDC_VSHIFT, TBM_SETPOS, TRUE, 100);
  813. g_ConfigThis->forceshift=1;
  814. g_ConfigThis->forceredraw=1;
  815. g_ConfigThis->shiftinit=1;
  816. }
  817. if (LOWORD(wParam) == IDC_EDIT)
  818. if (HIWORD(wParam) == EN_CHANGE)
  819. {
  820. int l;
  821. if (g_ConfigThis->text)
  822. GlobalFree(g_ConfigThis->text);
  823. l = SendDlgItemMessage(hwndDlg, IDC_EDIT, WM_GETTEXTLENGTH, 0, 0);
  824. if (!l)
  825. g_ConfigThis->text = NULL;
  826. else
  827. {
  828. g_ConfigThis->text = (char *)GlobalAlloc(GMEM_FIXED,l+2);
  829. GetDlgItemText(hwndDlg, IDC_EDIT, g_ConfigThis->text, l+1);
  830. }
  831. g_ConfigThis->forceredraw=1;
  832. }
  833. if (LOWORD(wParam) == IDC_CHOOSEFONT)
  834. {
  835. g_ConfigThis->cf.hwndOwner = hwndDlg;
  836. ChooseFont(&(g_ConfigThis->cf));
  837. g_ConfigThis->updating=true;
  838. g_ConfigThis->myFont = CreateFontIndirect(&(g_ConfigThis->lf));
  839. g_ConfigThis->forceredraw=1;
  840. if (g_ConfigThis->hOldFont)
  841. SelectObject(g_ConfigThis->hBitmapDC, g_ConfigThis->hOldFont);
  842. if (g_ConfigThis->myFont)
  843. g_ConfigThis->hOldFont = (HFONT)SelectObject(g_ConfigThis->hBitmapDC, g_ConfigThis->myFont);
  844. else
  845. g_ConfigThis->hOldFont = NULL;
  846. g_ConfigThis->updating=false;
  847. }
  848. if ((LOWORD(wParam) == IDC_CHECK1) ||
  849. (LOWORD(wParam) == IDC_ONBEAT) ||
  850. (LOWORD(wParam) == IDC_ADDITIVE) ||
  851. (LOWORD(wParam) == IDC_REPLACE) ||
  852. (LOWORD(wParam) == IDC_BLANKS) ||
  853. (LOWORD(wParam) == IDC_RANDOMPOS) ||
  854. (LOWORD(wParam) == IDC_OUTLINE) ||
  855. (LOWORD(wParam) == IDC_SHADOW) ||
  856. (LOWORD(wParam) == IDC_PLAIN) ||
  857. (LOWORD(wParam) == IDC_HLEFT) ||
  858. (LOWORD(wParam) == IDC_HRIGHT) ||
  859. (LOWORD(wParam) == IDC_HCENTER) ||
  860. (LOWORD(wParam) == IDC_VTOP) ||
  861. (LOWORD(wParam) == IDC_VBOTTOM) ||
  862. (LOWORD(wParam) == IDC_VCENTER) ||
  863. (LOWORD(wParam) == IDC_RANDWORD) ||
  864. (LOWORD(wParam) == IDC_5050) )
  865. {
  866. g_ConfigThis->forceredraw=1;
  867. g_ConfigThis->randomword=IsDlgButtonChecked(hwndDlg,IDC_RANDWORD)?1:0;
  868. g_ConfigThis->enabled=IsDlgButtonChecked(hwndDlg,IDC_CHECK1)?1:0;
  869. g_ConfigThis->outline=IsDlgButtonChecked(hwndDlg,IDC_OUTLINE)?1:0;
  870. g_ConfigThis->shadow=IsDlgButtonChecked(hwndDlg,IDC_SHADOW)?1:0;
  871. g_ConfigThis->onbeat=IsDlgButtonChecked(hwndDlg,IDC_ONBEAT)?1:0;
  872. g_ConfigThis->blend=IsDlgButtonChecked(hwndDlg,IDC_ADDITIVE)?1:0;
  873. g_ConfigThis->blendavg=IsDlgButtonChecked(hwndDlg,IDC_5050)?1:0;
  874. if (g_ConfigThis->onbeat)
  875. SendDlgItemMessage(hwndDlg, IDC_SPEED, TBM_SETPOS, TRUE, (int)(g_ConfigThis->onbeatSpeed));
  876. else
  877. SendDlgItemMessage(hwndDlg, IDC_SPEED, TBM_SETPOS, TRUE, (int)(g_ConfigThis->normSpeed));
  878. g_ConfigThis->insertBlank=IsDlgButtonChecked(hwndDlg,IDC_BLANKS)?1:0;
  879. g_ConfigThis->randomPos=IsDlgButtonChecked(hwndDlg,IDC_RANDOMPOS)?1:0;
  880. g_ConfigThis->valign=IsDlgButtonChecked(hwndDlg,IDC_VTOP)?DT_TOP:g_ConfigThis->valign;
  881. g_ConfigThis->valign=IsDlgButtonChecked(hwndDlg,IDC_VCENTER)?DT_VCENTER:g_ConfigThis->valign;
  882. g_ConfigThis->valign=IsDlgButtonChecked(hwndDlg,IDC_VBOTTOM)?DT_BOTTOM:g_ConfigThis->valign;
  883. g_ConfigThis->halign=IsDlgButtonChecked(hwndDlg,IDC_HLEFT)?DT_LEFT:g_ConfigThis->halign;
  884. g_ConfigThis->halign=IsDlgButtonChecked(hwndDlg,IDC_HRIGHT)?DT_RIGHT:g_ConfigThis->halign;
  885. g_ConfigThis->halign=IsDlgButtonChecked(hwndDlg,IDC_HCENTER)?DT_CENTER:g_ConfigThis->halign;
  886. EnableWindow(GetDlgItem(hwndDlg, IDC_VTOP), g_ConfigThis->randomPos ? FALSE : TRUE);
  887. EnableWindow(GetDlgItem(hwndDlg, IDC_VBOTTOM), g_ConfigThis->randomPos ? FALSE : TRUE);
  888. EnableWindow(GetDlgItem(hwndDlg, IDC_VCENTER), g_ConfigThis->randomPos ? FALSE : TRUE);
  889. EnableWindow(GetDlgItem(hwndDlg, IDC_HLEFT), g_ConfigThis->randomPos ? FALSE : TRUE);
  890. EnableWindow(GetDlgItem(hwndDlg, IDC_HRIGHT), g_ConfigThis->randomPos ? FALSE : TRUE);
  891. EnableWindow(GetDlgItem(hwndDlg, IDC_HCENTER), g_ConfigThis->randomPos ? FALSE : TRUE);
  892. EnableWindow(GetDlgItem(hwndDlg, IDC_HSHIFT), g_ConfigThis->randomPos ? FALSE : TRUE);
  893. EnableWindow(GetDlgItem(hwndDlg, IDC_VSHIFT), g_ConfigThis->randomPos ? FALSE : TRUE);
  894. if ((LOWORD(wParam) == IDC_ONBEAT) && g_ConfigThis->onbeat)
  895. g_ConfigThis->nb=g_ConfigThis->onbeatSpeed;
  896. if ((LOWORD(wParam) == IDC_RANDOMPOS) && g_ConfigThis->randomPos)
  897. g_ConfigThis->forcealign=1;
  898. }
  899. if (LOWORD(wParam) == IDC_DEFCOL ||LOWORD(wParam) == IDC_DEFOUTCOL) // handle clicks to nifty color button
  900. {
  901. int *a=&(LOWORD(wParam) == IDC_DEFCOL ? g_ConfigThis->color : g_ConfigThis->outlinecolor);
  902. static COLORREF custcolors[16];
  903. CHOOSECOLOR cs;
  904. cs.lStructSize = sizeof(cs);
  905. cs.hwndOwner = hwndDlg;
  906. cs.hInstance = 0;
  907. cs.rgbResult=((*a>>16)&0xff)|(*a&0xff00)|((*a<<16)&0xff0000);
  908. cs.lpCustColors = custcolors;
  909. cs.Flags = CC_RGBINIT|CC_FULLOPEN;
  910. if (ChooseColor(&cs))
  911. {
  912. *a = ((cs.rgbResult>>16)&0xff)|(cs.rgbResult&0xff00)|((cs.rgbResult<<16)&0xff0000);
  913. if (LOWORD(wParam) == IDC_DEFCOL)
  914. g_ConfigThis->color = *a;
  915. else
  916. g_ConfigThis->outlinecolor = *a;
  917. }
  918. InvalidateRect(GetDlgItem(hwndDlg,LOWORD(wParam)),NULL,TRUE);
  919. g_ConfigThis->updating=true;
  920. SetTextColor(g_ConfigThis->hBitmapDC, ((g_ConfigThis->color&0xFF0000) >> 16) | (g_ConfigThis->color& 0xFF00) | (g_ConfigThis->color&0xFF)<<16);
  921. g_ConfigThis->forceredraw=1;
  922. g_ConfigThis->updating=false;
  923. }
  924. }
  925. return 0;
  926. }
  927. HWND C_THISCLASS::conf(HINSTANCE hInstance, HWND hwndParent) // return NULL if no config dialog possible
  928. {
  929. g_ConfigThis = this;
  930. return WASABI_API_CREATEDIALOG(IDD_CFG_TEXT,hwndParent,g_DlgProc);
  931. }
  932. // export stuff
  933. C_RBASE *R_Text(char *desc) // creates a new effect object if desc is NULL, otherwise fills in desc with description
  934. {
  935. if (desc) { strcpy(desc,MOD_NAME); return NULL; }
  936. return (C_RBASE *) new C_THISCLASS();
  937. }
  938. #else
  939. C_RBASE *R_Text(char *desc) // creates a new effect object if desc is NULL, otherwise fills in desc with description
  940. { return NULL; }
  941. #endif