layer.cpp 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727
  1. #include <precomp.h>
  2. #include "layer.h"
  3. #include <api/wndmgr/resize.h>
  4. #include <api/wnd/cwndtrack.h>
  5. #ifdef WASABI_COMPILE_WNDMGR
  6. #include <api/wndmgr/layout.h>
  7. #include <api/wac/compon.h>
  8. #endif
  9. #ifdef WASABI_COMPILE_COMPONENTS
  10. #include <api/script/objects/compoobj.h>
  11. #endif
  12. #include <api/skin/skinparse.h>
  13. #if defined(WA3COMPATIBILITY) || defined(GEN_FF)
  14. #include <api/skin/widgets/fx_dmove.h>
  15. #endif
  16. #include <api/script/objects/sregion.h>
  17. #include <api/script/script.h>
  18. #include <api/script/scriptmgr.h>
  19. #include <api/service/svcs/svc_action.h>
  20. #include <api/script/vcpu.h>
  21. #include <api/wnd/notifmsg.h>
  22. #include <tataki/canvas/bltcanvas.h>
  23. #include <api/wnd/PaintCanvas.h>
  24. #define SNAP_X 1
  25. #define SNAP_Y 1
  26. #define FX_TIMER 0x0A1C
  27. const wchar_t layerXuiObjectStr[] = L"Layer"; // This is the xml tag
  28. char layerXuiSvcName[] = "Layer xui object"; // this is the name of the xuiservice
  29. XMLParamPair Layer::params[] =
  30. {
  31. {LAYER_SETMYCURSOR, L"CURSOR"},
  32. {LAYER_SETDBLCLICKACTION, L"DBLCLICKACTION"},
  33. {LAYER_DBLCLICKPARAM, L"DBLCLICKPARAM"},
  34. {LAYER_SETIMAGE, L"IMAGE"},
  35. {LAYER_SETINACTIVEIMAGE, L"INACTIVEIMAGE"},
  36. {LAYER_SETQUALITY, L"QUALITY"},
  37. {LAYER_SETREGION, L"REGION"},
  38. {LAYER_SETRESIZE, L"RESIZE"},
  39. {LAYER_SETSCALE, L"SCALE"},
  40. {LAYER_SETTILE, L"TILE"},
  41. };
  42. Layer::Layer()
  43. : resizer(0), resizeway(0), scaler(0), scalerway(0), scaling(0),
  44. rgn(NULL), secrgn(NULL), rgnclone(NULL), fx_wrap(0), fx_rect(0),
  45. fx_dmove(NULL)
  46. {
  47. getScriptObject()->vcpu_setInterface(layerGuid, (void *)static_cast<Layer *>(this));
  48. getScriptObject()->vcpu_setClassName(L"Layer");
  49. getScriptObject()->vcpu_setController(layerController);
  50. resizerect = 1;
  51. tiling = 0;
  52. l_customcursor = false;
  53. hasInactiveImage = 0;
  54. fx_on = 0;
  55. fx_bgfx = 0;
  56. fx_grid_x = 16;
  57. fx_grid_y = 16;
  58. fx_bilinear = 1;
  59. fx_alphamode = 0;
  60. fx_delay = 35;
  61. fx_timeron = 0;
  62. fx_clear = 1;
  63. fx_local = 1;
  64. fx_realtime = 0;
  65. last_w = last_h = -1;
  66. getGuiObject()->guiobject_setMover(1);
  67. setRectRgn(1);
  68. xuihandle = newXuiHandle();
  69. CreateXMLParameters(xuihandle);
  70. }
  71. void Layer::CreateXMLParameters(int master_handle)
  72. {
  73. //LAYER_PARENT::CreateXMLParameters(master_handle);
  74. int numParams = sizeof(params) / sizeof(params[0]);
  75. hintNumberOfParams(xuihandle, numParams);
  76. for (int i = 0;i < numParams;i++)
  77. addParam(xuihandle, params[i], XUI_ATTRIBUTE_IMPLIED);
  78. }
  79. Layer::~Layer()
  80. {
  81. WASABI_API_SYSCB->syscb_deregisterCallback(static_cast<SkinCallbackI*>(this));
  82. delete rgnclone;
  83. delete rgn;
  84. delete secrgn;
  85. delete fx_dmove;
  86. }
  87. int Layer::onInit()
  88. {
  89. LAYER_PARENT::onInit();
  90. WASABI_API_SYSCB->syscb_registerCallback(static_cast<SkinCallbackI*>(this));
  91. return 1;
  92. }
  93. int Layer::onPaint(Canvas *canvas)
  94. {
  95. PaintCanvas paintcanvas;
  96. if (canvas == NULL)
  97. {
  98. if (!paintcanvas.beginPaint(this)) return 0;
  99. canvas = &paintcanvas;
  100. }
  101. LAYER_PARENT::onPaint(canvas);
  102. if (!getBitmap()) return 0;
  103. int talpha = getPaintingAlpha();
  104. RegionI *orig = NULL;
  105. if (secrgn)
  106. {
  107. orig = new RegionI(canvas);
  108. api_region *clone = orig->clone();
  109. api_region *secclone = secrgn->clone();
  110. RECT dr;
  111. getClientRect(&dr);
  112. secclone->offset(dr.left, dr.top);
  113. clone->andRegion(secclone);
  114. canvas->selectClipRgn(clone);
  115. orig->disposeClone(clone);
  116. secrgn->disposeClone(secclone);
  117. }
  118. RECT r, srcR, cb, cr;
  119. getClientRect(&srcR);
  120. r = cr = srcR;
  121. if (canvas->getClipBox(&cb))
  122. {
  123. r.left = MAX(r.left, cb.left);
  124. r.top = MAX(r.top, cb.top);
  125. r.right = MIN(r.right, cb.right);
  126. r.bottom = MIN(r.bottom, cb.bottom);
  127. srcR = r;
  128. }
  129. layer_adjustDest(&cr);
  130. layer_adjustDest(&r);
  131. #if defined(WA3COMPATIBILITY) || defined(GEN_FF)
  132. int bmw = getBitmap()->getWidth();
  133. int bmh = getBitmap()->getHeight();
  134. int bmpitch = getBitmap()->getFullWidth();
  135. int *bmbits = (int*)getBitmap()->getBits();
  136. if (bmbits) bmbits += getBitmap()->getX() + getBitmap()->getY() * bmpitch;
  137. #endif
  138. if (getWidth() == (cr.right - cr.left) && getHeight() == (cr.bottom - cr.top))
  139. {
  140. int w = r.right - r.left, h = r.bottom - r.top;
  141. srcR.top = r.top - cr.top;
  142. srcR.left = r.left - cr.left;
  143. srcR.top += getSourceOffsetY();
  144. srcR.left += getSourceOffsetX();
  145. srcR.bottom = srcR.top + h;
  146. srcR.right = srcR.left + w;
  147. // FG> NOT READY FOR OPTIMIZATION YET
  148. #if defined(WA3COMPATIBILITY) || defined(GEN_FF)
  149. if (fx_on && fx_dmove && bmbits)
  150. {
  151. if (fx_bgfx)
  152. {
  153. if (!fx_dmove->getBltCanvas() || !fx_dmove->getBltCanvas()->getBits())
  154. fx_dmove->render(this, getWidth(), getHeight(), bmbits, bmw, bmh, bmpitch);
  155. int w, h, p, *bits = (int*)canvas->getBits();
  156. if (bits && !canvas->getDim(&w, &h, &p) &&
  157. cr.left + getWidth() < w && cr.top + getHeight() < h && cr.left >= 0 && cr.top >= 0)
  158. {
  159. fx_dmove->render(this, getWidth(), getHeight(), bits + cr.left + cr.top*w, getWidth(), getHeight(), w);
  160. }
  161. else
  162. {
  163. BltCanvas c(getWidth(), getHeight());
  164. canvas->blit(cr.left, cr.top, &c, 0, 0, getWidth(), getHeight());
  165. fx_dmove->render(this, getWidth(), getHeight(), (int *)c.getBits(),
  166. getWidth(), getHeight(), getWidth());
  167. }
  168. if (fx_dmove->getBltCanvas())
  169. fx_dmove->getBltCanvas()->blit(0, 0, canvas, cr.left, cr.top, getWidth(), getHeight());
  170. }
  171. else
  172. { // no bgfx
  173. if (fx_getClear() && fx_dmove->getBltCanvas() && fx_dmove->getBltCanvas()->getBits())
  174. fx_dmove->getBltCanvas()->fillBits(0);
  175. fx_dmove->render(this, getWidth(), getHeight(), bmbits, bmw, bmh, bmpitch);
  176. //SkinBitmap *b = NULL;
  177. if (fx_dmove->getBltCanvas())
  178. {
  179. fx_dmove->getBltCanvas()->stretchToRectAlpha(canvas, &srcR, &r, talpha);
  180. // b = fx_dmove->getBltCanvas()->getSkinBitmap();
  181. // if (b)
  182. // b->stretchToRectAlpha(canvas, &srcR, &r, talpha);
  183. }
  184. }
  185. }
  186. else
  187. #endif
  188. getBitmap()->stretchToRectAlpha(canvas, &srcR, &r, talpha);
  189. }
  190. else
  191. {
  192. if (r.right == r.left || r.bottom == r.top)
  193. {
  194. if (orig)
  195. {
  196. canvas->selectClipRgn(orig);
  197. delete orig; orig = 0;
  198. }
  199. return 0;
  200. }
  201. srcR.top = getSourceOffsetY();
  202. srcR.left = getSourceOffsetX();
  203. srcR.bottom = srcR.top + getHeight();
  204. srcR.right = srcR.left + getWidth();
  205. if (!tiling)
  206. {
  207. #if defined(WA3COMPATIBILITY) || defined(GEN_FF)
  208. if (fx_on && fx_dmove && bmbits)
  209. {
  210. if (fx_bgfx)
  211. {
  212. if (!fx_dmove->getBltCanvas() || !fx_dmove->getBltCanvas()->getBits())
  213. fx_dmove->render(this, cr.right - cr.left, cr.bottom - cr.top, bmbits, bmw, bmh, bmpitch);
  214. int w, h, p;
  215. if (canvas->getBits() && !canvas->getDim(&w, &h, &p) &&
  216. cr.right < w && cr.bottom < h && cr.left >= 0 && cr.top >= 0)
  217. {
  218. fx_dmove->render(this, cr.right - cr.left, cr.bottom - cr.top, (int *)canvas->getBits() + cr.left + cr.top*w,
  219. cr.right - cr.left, cr.bottom - cr.top, w);
  220. }
  221. else
  222. {
  223. BltCanvas c(cr.right - cr.left, cr.bottom - cr.top);
  224. canvas->blit(cr.left, cr.top, &c, 0, 0, cr.right - cr.left, cr.bottom - cr.top);
  225. fx_dmove->render(this, cr.right - cr.left, cr.bottom - cr.top, (int *)c.getBits(),
  226. cr.right - cr.left, cr.bottom - cr.top, cr.right - cr.left);
  227. }
  228. if (fx_dmove->getBltCanvas())
  229. fx_dmove->getBltCanvas()->blit(0, 0, canvas, cr.left, cr.top, cr.right - cr.left, cr.bottom - cr.top);
  230. }
  231. else
  232. {
  233. if (fx_getClear() && fx_dmove->getBltCanvas() && fx_dmove->getBltCanvas()->getBits())
  234. fx_dmove->getBltCanvas()->fillBits(0);
  235. fx_dmove->render(this, getWidth(), getHeight(), bmbits, bmw, bmh, bmpitch);
  236. //SkinBitmap *b = NULL;
  237. if (fx_dmove->getBltCanvas())
  238. {
  239. fx_dmove->getBltCanvas()->stretchToRectAlpha(canvas, &srcR, &cr, talpha);
  240. // b = fx_dmove->getBltCanvas()->getSkinBitmap();
  241. // if (b)
  242. // b->stretchToRectAlpha(canvas, &srcR, &cr, talpha);
  243. }
  244. }
  245. }
  246. else
  247. #endif
  248. {
  249. getBitmap()->stretchToRectAlpha(canvas, &srcR, &cr, talpha);
  250. }
  251. }
  252. else
  253. {
  254. getBitmap()->blitRectToTile(canvas, &cr, &srcR, 0, 0, talpha);
  255. }
  256. }
  257. if (orig)
  258. {
  259. canvas->selectClipRgn(orig);
  260. delete orig; orig = 0;
  261. }
  262. return 1;
  263. }
  264. int Layer::onResize()
  265. {
  266. LAYER_PARENT::onResize();
  267. RECT r;
  268. getClientRect(&r);
  269. int w = r.right - r.left;
  270. int h = r.bottom - r.top;
  271. if (w != last_w || h != last_h)
  272. invalidateRegionCache();
  273. return 1;
  274. }
  275. #pragma warning (disable : 4065)
  276. void Layer::timerCallback(int id)
  277. {
  278. switch (id)
  279. {
  280. #if defined(WA3COMPATIBILITY) || defined(GEN_FF)
  281. case FX_TIMER:
  282. fx_onFrame();
  283. invalidate();
  284. break;
  285. #endif
  286. default:
  287. LAYER_PARENT::timerCallback(id);
  288. break;
  289. }
  290. }
  291. #pragma warning (default: 4065)
  292. void Layer::invalidateRegionCache()
  293. {
  294. delete rgnclone;
  295. rgnclone = NULL;
  296. invalidateWindowRegion();
  297. }
  298. int Layer::setXuiParam(int _xuihandle, int attribid, const wchar_t *paramname, const wchar_t *strvalue)
  299. {
  300. if (xuihandle != _xuihandle) return LAYER_PARENT::setXuiParam(_xuihandle, attribid, paramname, strvalue);
  301. switch (attribid)
  302. {
  303. case LAYER_SETIMAGE:
  304. setBitmap(strvalue);
  305. break;
  306. case LAYER_SETRESIZE:
  307. setResize(SkinParser::parseResize(strvalue));
  308. if (resizer) getGuiObject()->guiobject_setMover(0);
  309. break;
  310. case LAYER_SETSCALE:
  311. setScaler(SkinParser::parseResize(strvalue));
  312. if (scaler) getGuiObject()->guiobject_setMover(0);
  313. break;
  314. case LAYER_SETREGION:
  315. setRegionFromBitmap(strvalue);
  316. break;
  317. case LAYER_SETTILE:
  318. setTiling(WTOI(strvalue));
  319. break;
  320. case LAYER_SETDBLCLICKACTION:
  321. dblClickAction = strvalue;
  322. break;
  323. case LAYER_DBLCLICKPARAM:
  324. setDblClickParam(strvalue);
  325. break;
  326. case LAYER_SETINACTIVEIMAGE:
  327. setInactiveBitmap(strvalue);
  328. break;
  329. case LAYER_SETMYCURSOR:
  330. l_customcursor = true;
  331. getGuiObject()->guiobject_setCursor(strvalue);
  332. break;
  333. case LAYER_SETQUALITY:
  334. bitmap.setResamplingMode(WTOI(strvalue));
  335. break;
  336. default:
  337. return 0;
  338. }
  339. return 1;
  340. }
  341. int Layer::getPreferences(int what)
  342. {
  343. if (what == SUGGESTED_W)
  344. return getWidth();
  345. if (what == SUGGESTED_H)
  346. return getHeight();
  347. return LAYER_PARENT::getPreferences(what);
  348. }
  349. int Layer::getSourceOffsetX()
  350. {
  351. return 0;
  352. }
  353. int Layer::getSourceOffsetY()
  354. {
  355. return 0;
  356. }
  357. void Layer::setBitmap(const wchar_t *name)
  358. {
  359. bitmapname = name;
  360. bitmap = name;
  361. deleteRegion();
  362. makeRegion();
  363. notifyParent(ChildNotify::AUTOWHCHANGED);
  364. if (isInited()) invalidate();
  365. }
  366. void Layer::setInactiveBitmap(const wchar_t *name)
  367. {
  368. inactiveImageName = name;
  369. inactiveBitmap = name;
  370. hasInactiveImage = 1;
  371. }
  372. void Layer::setDblClickParam(const wchar_t *p)
  373. {
  374. dblclickparam=p;
  375. }
  376. const wchar_t *Layer::getDblClickParam()
  377. {
  378. return dblclickparam;
  379. }
  380. int Layer::getWidth()
  381. {
  382. if (getBitmap()) return getBitmap()->getWidth();
  383. return 0;
  384. }
  385. int Layer::getHeight()
  386. {
  387. if (getBitmap()) return getBitmap()->getHeight();
  388. return 0;
  389. }
  390. int Layer::onLeftButtonDown(int x, int y)
  391. {
  392. LAYER_PARENT::onLeftButtonDown(x, y);
  393. ifc_window *d = getDesktopParent();
  394. #ifdef WASABI_COMPILE_WNDMGR
  395. Layout *_l = NULL;
  396. if (d != NULL)
  397. {
  398. _l = static_cast<Layout *>(d->getInterface(layoutGuid));
  399. if (_l && _l->isLocked()) return 1;
  400. }
  401. int need_resize = 0, need_scale = 0, need_move = 0;
  402. int dock = APPBAR_NOTDOCKED;
  403. int rw = applyResizeRestrictions(resizeway, &dock);
  404. int sw = (dock == APPBAR_NOTDOCKED) ? scalerway : RESIZE_NONE;
  405. if (resizer && rw != RESIZE_NONE && (!_l || _l->getResizable()))
  406. {
  407. if (scaler && sw != RESIZE_NONE && Std::keyModifier(STDKEY_ALT) && (!_l || _l->getScalable()))
  408. need_scale = 1;
  409. else
  410. need_resize = 1;
  411. }
  412. else if (scaler && sw != RESIZE_NONE && (!_l || _l->getScalable()))
  413. {
  414. need_scale = 1;
  415. }
  416. else if (getGuiObject()->guiobject_getMover())
  417. {
  418. need_move = 1;
  419. }
  420. Group *l = static_cast<Group *>(_l);
  421. if (need_move)
  422. {
  423. // do nothin'
  424. }
  425. else if (need_scale)
  426. {
  427. if (l)
  428. {
  429. l->beginScale();
  430. scaling = 1;
  431. }
  432. return 1;
  433. }
  434. else if (need_resize)
  435. {
  436. resizerect = 1;
  437. if (l)
  438. {
  439. clientToScreen(&x, &y);
  440. l->mouseResize(x, y, resizeway);
  441. }
  442. }
  443. #endif
  444. return 1;
  445. }
  446. int Layer::onLeftButtonUp(int x, int y)
  447. {
  448. LAYER_PARENT::onLeftButtonUp(x, y);
  449. #ifdef WASABI_COMPILE_WNDMGR
  450. if (scaling)
  451. {
  452. getGuiObject()->guiobject_getParentGroup()->endScale();
  453. scaling = 0;
  454. }
  455. #endif
  456. return 1;
  457. }
  458. void Layer::onCancelCapture()
  459. {
  460. LAYER_PARENT::onCancelCapture();
  461. scaling = 0;
  462. }
  463. int Layer::onMouseMove(int x, int y)
  464. {
  465. LAYER_PARENT::onMouseMove(x, y);
  466. POINT pos = {x, y};
  467. clientToScreen(&pos);
  468. #ifdef WASABI_COMPILE_WNDMGR
  469. if (scaling && getCapture())
  470. { // todo: resizing w/no rect
  471. if (!Std::keyDown(MK_LBUTTON))
  472. scaling = 0;
  473. else
  474. {
  475. RECT oldRect;
  476. RECT newRect;
  477. ifc_window *b = getRootParent();
  478. b->getWindowRect(&oldRect);
  479. newRect = oldRect;
  480. clientToScreen(&x, &y);
  481. int mask = 0;
  482. if (scalerway & RESIZE_BOTTOM)
  483. {
  484. newRect.bottom = y - y % SNAP_Y;
  485. mask |= BOTTOM;
  486. }
  487. if (scalerway & RESIZE_RIGHT)
  488. {
  489. newRect.right = x - x % SNAP_X;
  490. mask |= RIGHT;
  491. }
  492. if (scalerway & RESIZE_TOP)
  493. {
  494. newRect.top = y - y % SNAP_Y;
  495. mask |= TOP;
  496. }
  497. if (scalerway & RESIZE_LEFT)
  498. {
  499. newRect.left = x - x % SNAP_X;
  500. mask |= LEFT;
  501. }
  502. RECT dr = newRect;
  503. WASABI_API_WNDMGR->wndTrackDock(b, &dr, &newRect, mask | NOINTERSECT);
  504. if (dr.right - dr.left < 32) dr.right = dr.left + 32;
  505. if (dr.bottom - dr.top < 32) dr.bottom = dr.top + 32;
  506. if (MEMCMP(&dr, &oldRect, sizeof(RECT)))
  507. {
  508. RECT origRect;
  509. b->getClientRect(&origRect);
  510. double rx = (double)(dr.right - dr.left) / (double)(origRect.right - origRect.left);
  511. double ry = (double)(dr.bottom - dr.top) / (double)(origRect.bottom - origRect.top);
  512. double r = MAX(rx, ry);
  513. if (r != 0) b->setRenderRatio(r);
  514. }
  515. }
  516. }
  517. #endif
  518. return 1;
  519. }
  520. SkinBitmap *Layer::getBitmap()
  521. {
  522. return layer_getBitmap();
  523. }
  524. SkinBitmap *Layer::layer_getBitmap()
  525. {
  526. if (hasInactiveImage)
  527. if (!isActive())
  528. return inactiveBitmap.getBitmap();
  529. return bitmap.getBitmap();
  530. }
  531. const wchar_t *Layer::layer_getBitmapName()
  532. {
  533. return bitmapname;
  534. }
  535. int Layer::applyResizeRestrictions(int way, int *side)
  536. {
  537. ifc_window *rw = getDesktopParent();
  538. int dock = APPBAR_NOTDOCKED;
  539. if (side) *side = dock;
  540. if (rw)
  541. {
  542. Layout *l = (Layout *)rw->getInterface(layoutGuid);
  543. if (l) dock = l->appbar_getSide();
  544. }
  545. if (dock == APPBAR_NOTDOCKED) return way;
  546. /*
  547. switch (way) {
  548. case RESIZE_TOPLEFT:
  549. if (dock == APPBAR_TOP || dock == APPBAR_LEFT) return RESIZE_NONE;
  550. break;
  551. case RESIZE_BOTTOMRIGHT:
  552. if (dock == APPBAR_RIGHT || dock == APPBAR_BOTTOM) return RESIZE_NONE;
  553. break;
  554. case RESIZE_TOPRIGHT:
  555. if (dock == APPBAR_TOP || dock == APPBAR_RIGHT) return RESIZE_NONE;
  556. break;
  557. case RESIZE_BOTTOMLEFT:
  558. if (dock == APPBAR_BOTTOM || dock == APPBAR_LEFT) return RESIZE_NONE;
  559. break;
  560. case RESIZE_TOP:
  561. if (dock == APPBAR_TOP) return RESIZE_NONE;
  562. break;
  563. case RESIZE_BOTTOM:
  564. if (dock == APPBAR_BOTTOM) return RESIZE_NONE;
  565. break;
  566. case RESIZE_LEFT:
  567. if (dock == APPBAR_LEFT) return RESIZE_NONE;
  568. break;
  569. case RESIZE_RIGHT:
  570. if (dock == APPBAR_RIGHT) return RESIZE_NONE;
  571. break;
  572. }
  573. return way;*/
  574. if (dock != APPBAR_NOTDOCKED) return RESIZE_NONE;
  575. return way;
  576. }
  577. int Layer::getCursorType(int x, int y)
  578. {
  579. // Return our user cursor if we have one (even when we are resizable!)
  580. if (l_customcursor)
  581. {
  582. return BASEWND_CURSOR_USERSET;
  583. }
  584. // Then check if our layer is used to resize or scale the wnd
  585. ifc_window *d = getDesktopParent();
  586. int scalable = 1;
  587. int resizable = 1;
  588. Layout *_l = NULL;
  589. if (d != NULL)
  590. {
  591. _l = static_cast<Layout *>(d->getInterface(layoutGuid));
  592. if (_l)
  593. {
  594. scalable = _l->getScalable();
  595. resizable = _l->getResizable();
  596. }
  597. }
  598. if (!_l || (!_l->isLocked() && (resizer || scaler)))
  599. {
  600. int dock = APPBAR_NOTDOCKED;
  601. int r = 0;
  602. if (resizer && resizable)
  603. {
  604. if (scaler && scalable)
  605. {
  606. if (Std::keyModifier(STDKEY_ALT))
  607. {
  608. r = applyResizeRestrictions(scalerway, &dock);
  609. if (dock != APPBAR_NOTDOCKED) r = RESIZE_NONE;
  610. }
  611. else
  612. {
  613. r = applyResizeRestrictions(resizeway);
  614. }
  615. }
  616. else
  617. {
  618. r = applyResizeRestrictions(resizeway);
  619. }
  620. }
  621. if (scaler && scalable)
  622. {
  623. r = applyResizeRestrictions(scalerway, &dock);
  624. if (dock != APPBAR_NOTDOCKED) r = RESIZE_NONE;
  625. }
  626. switch (r)
  627. {
  628. case RESIZE_TOPLEFT:
  629. case RESIZE_BOTTOMRIGHT:
  630. return BASEWND_CURSOR_NORTHWEST_SOUTHEAST;
  631. case RESIZE_TOPRIGHT:
  632. case RESIZE_BOTTOMLEFT:
  633. return BASEWND_CURSOR_NORTHEAST_SOUTHWEST;
  634. break;
  635. case RESIZE_TOP:
  636. case RESIZE_BOTTOM:
  637. return BASEWND_CURSOR_NORTHSOUTH;
  638. break;
  639. case RESIZE_LEFT:
  640. case RESIZE_RIGHT:
  641. return BASEWND_CURSOR_EASTWEST;
  642. break;
  643. }
  644. }
  645. // At leat we want to have a cursor so spit our the normal pointer
  646. return BASEWND_CURSOR_POINTER;
  647. }
  648. void Layer::setScaler(int r)
  649. {
  650. if (r != 0)
  651. {
  652. scaler = 1;
  653. scalerway = r;
  654. }
  655. else
  656. {
  657. resizer = 0;
  658. scalerway = 0;
  659. }
  660. }
  661. void Layer::setResize(int r)
  662. {
  663. if (r != 0)
  664. {
  665. resizer = 1;
  666. resizeway = r;
  667. }
  668. else
  669. {
  670. resizer = 0;
  671. resizeway = 0;
  672. }
  673. }
  674. api_region *Layer::getBitmapRegion()
  675. {
  676. return rgn;
  677. }
  678. api_region *Layer::getRegion()
  679. {
  680. api_region *_rgn = getBitmapRegion();
  681. if (!_rgn) return NULL;
  682. if (!rgnclone)
  683. {
  684. rgnclone = new RegionI();
  685. rgnclone->addRegion(_rgn);
  686. }
  687. else
  688. return rgnclone;
  689. float w, h;
  690. RECT r;
  691. getClientRect(&r);
  692. if (r.right - r.left == 0 || r.bottom - r.top == 0) return NULL;
  693. last_w = r.right - r.left;
  694. last_h = r.bottom - r.top;
  695. if (getWidth() == 0 || getHeight() == 0) return NULL;
  696. w = (float)(last_w) / (float)getWidth();
  697. h = (float)(last_h) / (float)getHeight();
  698. if (!w || !h) return NULL;
  699. if (!tiling)
  700. {
  701. if (w != 1.0 || h != 1.0)
  702. {
  703. rgnclone->scale(w, h, TRUE);
  704. }
  705. }
  706. else
  707. {
  708. for (int j = 0;j < h;j++)
  709. {
  710. for (int i = 0;i < w;i++)
  711. {
  712. api_region *t = _rgn->clone();
  713. t->offset(i*getWidth(), j*getHeight());
  714. rgnclone->addRegion(t);
  715. _rgn->disposeClone(t);
  716. }
  717. }
  718. }
  719. RegionI _r(&r);
  720. _r.offset(-r.left, -r.top);
  721. rgnclone->andRegion(&_r);
  722. return rgnclone;
  723. }
  724. void Layer::setRegionOp(int i)
  725. {
  726. int old = getRegionOp();
  727. LAYER_PARENT::setRegionOp(i);
  728. if (!old && i) setRectRgn(0);
  729. }
  730. void Layer::makeRegion()
  731. {
  732. if (!bitmap.getBitmap())
  733. return;
  734. delete rgn;
  735. rgn = new RegionI(bitmap);
  736. invalidateRegionCache();
  737. }
  738. void Layer::deleteRegion()
  739. {
  740. if (!rgn) return;
  741. invalidateRegionCache();
  742. delete rgn;
  743. rgn = NULL;
  744. }
  745. int Layer::onLeftButtonDblClk(int x, int y)
  746. {
  747. // Martin> copied and adopted from textbase.cpp
  748. //if (!dblClickAction.isempty() && !VCPU::getComplete())
  749. if (dblClickAction)
  750. {
  751. #ifdef WASABI_COMPILE_WNDMGR
  752. const wchar_t *toCheck = L"SWITCH;";
  753. if (!_wcsnicmp(dblClickAction, toCheck, 7))
  754. {
  755. onLeftButtonUp(x, y);
  756. getGuiObject()->guiobject_getParentGroup()->getParentContainer()->switchToLayout(dblClickAction.getValue() + 7);
  757. return 0;
  758. }
  759. else
  760. {
  761. #endif
  762. svc_action *act = ActionEnum(dblClickAction).getNext();
  763. if (act)
  764. {
  765. int _x = x;
  766. int _y = y;
  767. clientToScreen(&_x, &_y);
  768. act->onAction(dblClickAction, getDblClickParam(), _x, _y, NULL, 0, this);
  769. //WASABI_API_WNDMGR->messageBox(L"on action; passed", L"debug", 0, NULL, NULL);
  770. SvcEnum::release(act);
  771. }
  772. #ifdef WASABI_COMPILE_WNDMGR
  773. }
  774. #endif
  775. }
  776. int r = LAYER_PARENT::onLeftButtonDblClk(x, y);
  777. return r;
  778. }
  779. void Layer::setRegionFromMap(SMap *map, int byte, int inversed)
  780. {
  781. if (secrgn)
  782. {
  783. invalidate();
  784. delete secrgn;
  785. secrgn = NULL;
  786. }
  787. //RECT r = {map->getBitmap()->getX(), map->getBitmap()->getY(), map->getBitmap()->getWidth(), map->getBitmap()->getHeight()};
  788. secrgn = new RegionI(map->getBitmap(), NULL, 0, 0, FALSE, 1, (unsigned char)byte, inversed);
  789. if (secrgn)
  790. invalidate();
  791. }
  792. void Layer::setRegion(SRegion *reg)
  793. {
  794. invalidate();
  795. delete secrgn;
  796. if (!reg)
  797. {
  798. secrgn = NULL; invalidate(); return;
  799. }
  800. secrgn = new RegionI();
  801. secrgn->addRegion(reg->getRegion());
  802. invalidate();
  803. }
  804. int Layer::wantSiblingInvalidations()
  805. {
  806. return fx_on;
  807. }
  808. int Layer::onSiblingInvalidateRgn(api_region *r, ifc_window *who, int who_idx, int my_idx)
  809. {
  810. if (!fx_on || !fx_bgfx || who_idx >= my_idx) return 0;
  811. RECT rr;
  812. getClientRect(&rr);
  813. if (rgn)
  814. {
  815. api_region *_r = rgn->clone();
  816. _r->offset(rr.left, rr.top);
  817. if (fx_local && !_r->doesIntersectRgn(r))
  818. {
  819. rgn->disposeClone(_r);
  820. return 0;
  821. }
  822. if (secrgn)
  823. {
  824. api_region *_rs = secrgn->clone();
  825. _rs->offset(rr.left, rr.top);
  826. _r->andRegion(_rs);
  827. secrgn->disposeClone(_rs);
  828. }
  829. r->addRegion(_r);
  830. rgn->disposeClone(_r);
  831. }
  832. else
  833. {
  834. RegionI _r(&rr);
  835. if (secrgn)
  836. {
  837. api_region *_rs = secrgn->clone();
  838. _rs->offset(rr.left, rr.top);
  839. _r.andRegion(_rs);
  840. secrgn->disposeClone(_rs);
  841. }
  842. if (fx_local && !_r.doesIntersectRgn(r))
  843. {
  844. return 0;
  845. }
  846. r->addRegion(&_r);
  847. }
  848. return 1;
  849. }
  850. void Layer::onSetVisible(int show)
  851. {
  852. LAYER_PARENT::onSetVisible(show);
  853. getGuiObject()->guiobject_onSetVisible(show);
  854. }
  855. int Layer::onActivate()
  856. {
  857. invalidate();
  858. return 0;
  859. }
  860. int Layer::onDeactivate()
  861. {
  862. invalidate();
  863. return 0;
  864. }
  865. void Layer::setTiling(int t)
  866. {
  867. if (tiling == t) return;
  868. tiling = t;
  869. invalidate();
  870. }
  871. int Layer::getTiling()
  872. {
  873. return tiling;
  874. }
  875. void Layer::onBeginResize(RECT r)
  876. {
  877. scriptVar l = SOM::makeVar(SCRIPT_INT);
  878. SOM::assign(&l, r.left);
  879. scriptVar t = SOM::makeVar(SCRIPT_INT);
  880. SOM::assign(&t, r.top);
  881. scriptVar w = SOM::makeVar(SCRIPT_INT);
  882. SOM::assign(&w, r.right - r.left);
  883. scriptVar h = SOM::makeVar(SCRIPT_INT);
  884. SOM::assign(&h, r.bottom - r.top);
  885. script_vcpu_onBeginResize(SCRIPT_CALL, getScriptObject(), l, t, w, h);
  886. }
  887. void Layer::onEndResize(RECT r)
  888. {
  889. scriptVar l = SOM::makeVar(SCRIPT_INT);
  890. SOM::assign(&l, r.left);
  891. scriptVar t = SOM::makeVar(SCRIPT_INT);
  892. SOM::assign(&t, r.top);
  893. scriptVar w = SOM::makeVar(SCRIPT_INT);
  894. SOM::assign(&w, r.right - r.left);
  895. scriptVar h = SOM::makeVar(SCRIPT_INT);
  896. SOM::assign(&h, r.bottom - r.top);
  897. script_vcpu_onEndResize(SCRIPT_CALL, getScriptObject(), l, t, w, h);
  898. }
  899. #if defined(WA3COMPATIBILITY) || defined(GEN_FF)
  900. void Layer::fx_setEnabled(int i)
  901. {
  902. static int inited = 0;
  903. if (fx_getEnabled() == !!i) return;
  904. fx_on = !!i;
  905. if (fx_on)
  906. {
  907. if (!inited)
  908. fx_onInit();
  909. fx_dmove = new FxDynamicMove;
  910. fx_dmove->setBilinear(fx_getBilinear());
  911. if (fx_getAlphaMode())
  912. fx_dmove->setAlphaMode(1 | (fx_getBgFx() ? 2 : 0));
  913. else fx_setAlphaMode(0);
  914. fx_dmove->setAlphaOnce(fx_alphaonce);
  915. fx_dmove->setRect(fx_getRect());
  916. fx_dmove->setWrap(fx_getWrap());
  917. fx_dmove->setGridSize(fx_grid_x, fx_grid_y);
  918. if (fx_realtime)
  919. {
  920. setTimer(FX_TIMER, fx_delay);
  921. fx_timeron = 1;
  922. }
  923. }
  924. else
  925. {
  926. if (fx_timeron)
  927. {
  928. killTimer(FX_TIMER);
  929. fx_timeron = 0;
  930. }
  931. delete fx_dmove;
  932. fx_dmove = NULL;
  933. }
  934. invalidate();
  935. }
  936. int Layer::fx_getEnabled(void)
  937. {
  938. return fx_on;
  939. }
  940. void Layer::fx_setWrap(int i)
  941. {
  942. if (fx_getWrap() == !!i) return;
  943. fx_wrap = !!i;
  944. if (fx_dmove) fx_dmove->setWrap(fx_wrap);
  945. invalidate();
  946. }
  947. int Layer::fx_getWrap(void)
  948. {
  949. return fx_wrap;
  950. }
  951. void Layer::fx_setRect(int i)
  952. {
  953. if (fx_getRect() == !!i) return;
  954. fx_rect = !!i;
  955. if (fx_dmove) fx_dmove->setRect(fx_rect);
  956. invalidate();
  957. }
  958. int Layer::fx_getRect(void)
  959. {
  960. return fx_rect;
  961. }
  962. int Layer::fx_getAlphaMode()
  963. {
  964. if (!fx_alphamode) return 0;
  965. if (fx_alphaonce) return 2;
  966. return 1;
  967. }
  968. void Layer::fx_setAlphaMode(int i)
  969. {
  970. if (i == 2)
  971. {
  972. i = 1;
  973. fx_alphaonce = 1;
  974. if (fx_dmove) fx_dmove->setAlphaOnce(1);
  975. }
  976. else
  977. {
  978. fx_alphaonce = 0;
  979. if (fx_dmove) fx_dmove->setAlphaOnce(0);
  980. }
  981. if (fx_getAlphaMode() == !!i) return;
  982. fx_alphamode = !!i;
  983. if (fx_dmove)
  984. {
  985. if (fx_getAlphaMode())
  986. fx_dmove->setAlphaMode(1 | (fx_getBgFx() ? 2 : 0));
  987. else
  988. fx_dmove->setAlphaMode(0);
  989. }
  990. invalidate();
  991. }
  992. int Layer::fx_getBilinear()
  993. {
  994. return fx_bilinear;
  995. }
  996. void Layer::fx_setBilinear(int i)
  997. {
  998. if (fx_getBilinear() == !!i) return;
  999. fx_bilinear = !!i;
  1000. if (fx_dmove) fx_dmove->setBilinear(fx_bilinear);
  1001. invalidate();
  1002. }
  1003. int Layer::fx_getBgFx()
  1004. {
  1005. return fx_bgfx;
  1006. }
  1007. void Layer::fx_setBgFx(int i)
  1008. {
  1009. if (fx_getBgFx() == !!i) return;
  1010. fx_bgfx = !!i;
  1011. if (fx_dmove) fx_dmove->setCanCache(!i);
  1012. if (fx_dmove && fx_getAlphaMode())
  1013. {
  1014. fx_dmove->setAlphaMode(1 | (fx_getBgFx() ? 2 : 0));
  1015. }
  1016. invalidate();
  1017. }
  1018. int Layer::fx_getSpeed()
  1019. {
  1020. return fx_delay;
  1021. }
  1022. void Layer::fx_setSpeed(int s)
  1023. {
  1024. if (fx_getSpeed() == s) return;
  1025. fx_delay = s;
  1026. if (fx_timeron)
  1027. {
  1028. killTimer(FX_TIMER);
  1029. fx_timeron = 0;
  1030. }
  1031. if (fx_on && fx_realtime)
  1032. {
  1033. setTimer(FX_TIMER, fx_delay);
  1034. fx_timeron = 1;
  1035. }
  1036. }
  1037. int Layer::fx_getClear()
  1038. {
  1039. return fx_clear;
  1040. }
  1041. void Layer::fx_setClear(int i)
  1042. {
  1043. if (fx_getClear() == !!i) return;
  1044. fx_clear = !!i;
  1045. }
  1046. int Layer::fx_getRealtime()
  1047. {
  1048. return fx_realtime;
  1049. }
  1050. void Layer::fx_setRealtime(int i)
  1051. {
  1052. if (fx_getRealtime() == !!i) return;
  1053. fx_realtime = !!i;
  1054. }
  1055. int Layer::fx_getLocalized()
  1056. {
  1057. return fx_local;
  1058. }
  1059. void Layer::fx_setLocalized(int i)
  1060. {
  1061. if (fx_getLocalized() == !!i) return;
  1062. fx_local = !!i;
  1063. }
  1064. void Layer::fx_setGridSize(int x, int y)
  1065. {
  1066. fx_grid_x = x;
  1067. fx_grid_y = y;
  1068. if (!fx_dmove) return;
  1069. fx_dmove->setGridSize(x, y);
  1070. }
  1071. void Layer::fx_update(void)
  1072. {
  1073. RECT r;
  1074. getClientRect(&r);
  1075. if (fx_realtime && !isMinimized())
  1076. cascadeRepaintRect(&r);
  1077. else
  1078. invalidateRect(&r);
  1079. }
  1080. void Layer::fx_restart(void)
  1081. {
  1082. fx_onInit();
  1083. if (fx_dmove && fx_dmove->getBltCanvas() && fx_dmove->getBltCanvas()->getBits())
  1084. fx_dmove->getBltCanvas()->fillBits(0);
  1085. // todo: reset need_alpha in fx_dmove
  1086. }
  1087. void Layer::fx_onInit(void)
  1088. {
  1089. script_vcpu_fx_onInit(SCRIPT_CALL, getScriptObject());
  1090. }
  1091. void Layer::fx_onFrame(void)
  1092. {
  1093. script_vcpu_fx_onFrame(SCRIPT_CALL, getScriptObject());
  1094. }
  1095. double Layer::fx_onGetPixelA(double r, double d, double x, double y)
  1096. {
  1097. scriptVar _x = SOM::makeVar(SCRIPT_DOUBLE);
  1098. scriptVar _y = SOM::makeVar(SCRIPT_DOUBLE);
  1099. scriptVar _r = SOM::makeVar(SCRIPT_DOUBLE);
  1100. scriptVar _d = SOM::makeVar(SCRIPT_DOUBLE);
  1101. SOM::assign(&_x, x);
  1102. SOM::assign(&_y, y);
  1103. SOM::assign(&_r, r);
  1104. SOM::assign(&_d, d);
  1105. scriptVar v = script_vcpu_fx_onGetPixelA(SCRIPT_CALL, getScriptObject(), _r, _d, _x, _y);
  1106. return (v.type == 0) ? 0.5 : v.data.ddata;
  1107. }
  1108. double Layer::fx_onGetPixelX(double r, double d, double x, double y)
  1109. {
  1110. scriptVar _x = SOM::makeVar(SCRIPT_DOUBLE);
  1111. scriptVar _y = SOM::makeVar(SCRIPT_DOUBLE);
  1112. scriptVar _r = SOM::makeVar(SCRIPT_DOUBLE);
  1113. scriptVar _d = SOM::makeVar(SCRIPT_DOUBLE);
  1114. SOM::assign(&_x, x);
  1115. SOM::assign(&_y, y);
  1116. SOM::assign(&_r, r);
  1117. SOM::assign(&_d, d);
  1118. scriptVar v = script_vcpu_fx_onGetPixelX(SCRIPT_CALL, getScriptObject(), _r, _d, _x, _y);
  1119. return (v.type == 0) ? x : v.data.ddata;
  1120. }
  1121. double Layer::fx_onGetPixelY(double r, double d, double x, double y)
  1122. {
  1123. scriptVar _x = SOM::makeVar(SCRIPT_DOUBLE);
  1124. scriptVar _y = SOM::makeVar(SCRIPT_DOUBLE);
  1125. scriptVar _r = SOM::makeVar(SCRIPT_DOUBLE);
  1126. scriptVar _d = SOM::makeVar(SCRIPT_DOUBLE);
  1127. SOM::assign(&_x, x);
  1128. SOM::assign(&_y, y);
  1129. SOM::assign(&_r, r);
  1130. SOM::assign(&_d, d);
  1131. scriptVar v = script_vcpu_fx_onGetPixelY(SCRIPT_CALL, getScriptObject(), _r, _d, _x, _y);
  1132. return (v.type == 0) ? y : v.data.ddata;
  1133. }
  1134. double Layer::fx_onGetPixelR(double r, double d, double x, double y)
  1135. {
  1136. scriptVar _x = SOM::makeVar(SCRIPT_DOUBLE);
  1137. scriptVar _y = SOM::makeVar(SCRIPT_DOUBLE);
  1138. scriptVar _r = SOM::makeVar(SCRIPT_DOUBLE);
  1139. scriptVar _d = SOM::makeVar(SCRIPT_DOUBLE);
  1140. SOM::assign(&_x, x);
  1141. SOM::assign(&_y, y);
  1142. SOM::assign(&_r, r);
  1143. SOM::assign(&_d, d);
  1144. scriptVar v = script_vcpu_fx_onGetPixelR(SCRIPT_CALL, getScriptObject(), _r, _d, _x, _y);
  1145. return (v.type == 0) ? r : v.data.ddata;
  1146. }
  1147. double Layer::fx_onGetPixelD(double r, double d, double x, double y)
  1148. {
  1149. scriptVar _x = SOM::makeVar(SCRIPT_DOUBLE);
  1150. scriptVar _y = SOM::makeVar(SCRIPT_DOUBLE);
  1151. scriptVar _r = SOM::makeVar(SCRIPT_DOUBLE);
  1152. scriptVar _d = SOM::makeVar(SCRIPT_DOUBLE);
  1153. SOM::assign(&_x, x);
  1154. SOM::assign(&_y, y);
  1155. SOM::assign(&_r, r);
  1156. SOM::assign(&_d, d);
  1157. scriptVar v = script_vcpu_fx_onGetPixelD(SCRIPT_CALL, getScriptObject(), _r, _d, _x, _y);
  1158. return (v.type == 0) ? d : v.data.ddata;
  1159. }
  1160. #endif
  1161. int Layer::skincb_onColorThemeChanged(const wchar_t *newcolortheme)
  1162. {
  1163. #if defined(WA3COMPATIBILITY) || defined(GEN_FF)
  1164. if (fx_getEnabled())
  1165. {
  1166. fx_dmove->flushCache();
  1167. fx_update();
  1168. }
  1169. #endif
  1170. return 0;
  1171. }
  1172. void Layer::setRegionFromBitmap(const wchar_t *bmpid)
  1173. {
  1174. delete secrgn;
  1175. secrgn = NULL;
  1176. if (bmpid == NULL || *bmpid == '\0')
  1177. return;
  1178. bool invert = (*bmpid == '!');
  1179. if (invert) bmpid++;
  1180. SkinBitmap b(bmpid);
  1181. secrgn = new RegionI(&b, NULL, 0, 0, invert);
  1182. }
  1183. LayerScriptController _layerController;
  1184. LayerScriptController *layerController = &_layerController;
  1185. // -- Functions table -------------------------------------
  1186. function_descriptor_struct LayerScriptController::exportedFunction[] = {
  1187. {L"setRegionFromMap", 3, (void*)Layer::script_vcpu_setRegionFromMap },
  1188. {L"setRegion", 1, (void*)Layer::script_vcpu_setRegion },
  1189. {L"isInvalid", 0, (void*)Layer::script_vcpu_isInvalid },
  1190. #ifdef WASABI_COMPILE_WNDMGR
  1191. {L"onBeginResize", 4, (void*)Layer::script_vcpu_onBeginResize },
  1192. {L"onEndResize", 4, (void*)Layer::script_vcpu_onEndResize },
  1193. #endif
  1194. #if defined(WA3COMPATIBILITY) || defined(GEN_FF)
  1195. {
  1196. L"fx_setEnabled", 1, (void*)Layer::script_vcpu_fx_setEnabled
  1197. },
  1198. {L"fx_getEnabled", 0, (void*)Layer::script_vcpu_fx_getEnabled },
  1199. {L"fx_onInit", 0, (void*)Layer::script_vcpu_fx_onInit },
  1200. {L"fx_onFrame", 0, (void*)Layer::script_vcpu_fx_onFrame },
  1201. {L"fx_onGetPixelR", 4, (void*)Layer::script_vcpu_fx_onGetPixelR },
  1202. {L"fx_onGetPixelD", 4, (void*)Layer::script_vcpu_fx_onGetPixelD },
  1203. {L"fx_onGetPixelX", 4, (void*)Layer::script_vcpu_fx_onGetPixelX },
  1204. {L"fx_onGetPixelY", 4, (void*)Layer::script_vcpu_fx_onGetPixelY },
  1205. {L"fx_onGetPixelA", 4, (void*)Layer::script_vcpu_fx_onGetPixelA },
  1206. {L"fx_setWrap", 1, (void*)Layer::script_vcpu_fx_setWrap },
  1207. {L"fx_getWrap", 0, (void*)Layer::script_vcpu_fx_getWrap },
  1208. {L"fx_setRect", 1, (void*)Layer::script_vcpu_fx_setRect },
  1209. {L"fx_getRect", 0, (void*)Layer::script_vcpu_fx_getRect },
  1210. {L"fx_setBgFx", 1, (void*)Layer::script_vcpu_fx_setBgFx },
  1211. {L"fx_getBgFx", 0, (void*)Layer::script_vcpu_fx_getBgFx },
  1212. {L"fx_setClear", 1, (void*)Layer::script_vcpu_fx_setClear },
  1213. {L"fx_getClear", 0, (void*)Layer::script_vcpu_fx_getClear },
  1214. {L"fx_setSpeed", 1, (void*)Layer::script_vcpu_fx_setSpeed },
  1215. {L"fx_getSpeed", 0, (void*)Layer::script_vcpu_fx_getSpeed },
  1216. {L"fx_setRealtime", 1, (void*)Layer::script_vcpu_fx_setRealtime },
  1217. {L"fx_getRealtime", 0, (void*)Layer::script_vcpu_fx_getRealtime },
  1218. {L"fx_setLocalized", 1, (void*)Layer::script_vcpu_fx_setLocalized },
  1219. {L"fx_getLocalized", 0, (void*)Layer::script_vcpu_fx_getLocalized },
  1220. {L"fx_setBilinear", 1, (void*)Layer::script_vcpu_fx_setBilinear },
  1221. {L"fx_getBilinear", 0, (void*)Layer::script_vcpu_fx_getBilinear },
  1222. {L"fx_setAlphaMode", 1, (void*)Layer::script_vcpu_fx_setAlphaMode },
  1223. {L"fx_getAlphaMode", 0, (void*)Layer::script_vcpu_fx_getAlphaMode },
  1224. {L"fx_setGridSize", 2, (void*)Layer::script_vcpu_fx_setGridSize },
  1225. {L"fx_update", 0, (void*)Layer::script_vcpu_fx_update },
  1226. {L"fx_restart", 0, (void*)Layer::script_vcpu_fx_restart },
  1227. #endif
  1228. };
  1229. // --------------------------------------------------------
  1230. const wchar_t *LayerScriptController::getClassName()
  1231. {
  1232. return L"Layer";
  1233. }
  1234. const wchar_t *LayerScriptController::getAncestorClassName()
  1235. {
  1236. return L"GuiObject";
  1237. }
  1238. ScriptObject *LayerScriptController::instantiate()
  1239. {
  1240. Layer *l = new Layer;
  1241. ASSERT(l != NULL);
  1242. return l->getScriptObject();
  1243. }
  1244. void LayerScriptController::destroy(ScriptObject *o)
  1245. {
  1246. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1247. ASSERT(l != NULL);
  1248. delete l;
  1249. }
  1250. void *LayerScriptController::encapsulate(ScriptObject *o)
  1251. {
  1252. return NULL; // no encapsulation for layer yet
  1253. }
  1254. void LayerScriptController::deencapsulate(void *o)
  1255. {}
  1256. int LayerScriptController::getNumFunctions()
  1257. {
  1258. return sizeof(exportedFunction) / sizeof(function_descriptor_struct);
  1259. }
  1260. const function_descriptor_struct *LayerScriptController::getExportedFunctions()
  1261. {
  1262. return exportedFunction;
  1263. }
  1264. GUID LayerScriptController::getClassGuid()
  1265. {
  1266. return layerGuid;
  1267. }
  1268. //------------------------------------------------------------------------
  1269. scriptVar Layer::script_vcpu_onBeginResize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar left, scriptVar top, scriptVar width, scriptVar height)
  1270. {
  1271. SCRIPT_FUNCTION_INIT;
  1272. PROCESS_HOOKS4(o, layerController, left, top, width, height);
  1273. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1274. SCRIPT_EXEC_EVENT4(o, left, top, width, height);
  1275. }
  1276. scriptVar Layer::script_vcpu_onEndResize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar left, scriptVar top, scriptVar width, scriptVar height)
  1277. {
  1278. SCRIPT_FUNCTION_INIT;
  1279. PROCESS_HOOKS4(o, layerController, left, top, width, height);
  1280. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1281. SCRIPT_EXEC_EVENT4(o, left, top, width, height);
  1282. }
  1283. scriptVar Layer::script_vcpu_setRegionFromMap(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar map, scriptVar byte, scriptVar inv)
  1284. {
  1285. SCRIPT_FUNCTION_INIT
  1286. ASSERT(SOM::isNumeric(&byte));
  1287. ASSERT(SOM::isNumeric(&inv));
  1288. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1289. SMap *m = static_cast<SMap *>(GET_SCRIPT_OBJECT_AS(map, mapGuid));
  1290. if (l) l->setRegionFromMap(m, GET_SCRIPT_INT(byte), GET_SCRIPT_INT(inv));
  1291. RETURN_SCRIPT_VOID;
  1292. }
  1293. scriptVar Layer::script_vcpu_setRegion(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar reg)
  1294. {
  1295. SCRIPT_FUNCTION_INIT
  1296. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1297. SRegion *r = static_cast<SRegion *>(GET_SCRIPT_OBJECT_AS(reg, regionGuid));
  1298. if (l) l->setRegion(r);
  1299. RETURN_SCRIPT_VOID;
  1300. }
  1301. bool Layer::layer_isInvalid()
  1302. {
  1303. SkinBitmap *b = layer_getBitmap();
  1304. if (b)
  1305. return !!b->isInvalid();
  1306. else
  1307. return true;
  1308. }
  1309. scriptVar Layer::script_vcpu_isInvalid(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1310. {
  1311. SCRIPT_FUNCTION_INIT
  1312. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1313. if (l)
  1314. {
  1315. return MAKE_SCRIPT_INT(l->layer_isInvalid()?1:0);
  1316. }
  1317. return MAKE_SCRIPT_INT(1);
  1318. }
  1319. #if defined(WA3COMPATIBILITY) || defined(GEN_FF)
  1320. scriptVar Layer::script_vcpu_fx_setEnabled(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a)
  1321. {
  1322. SCRIPT_FUNCTION_INIT
  1323. ASSERT(SOM::isNumeric(&a));
  1324. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1325. if (l) l->fx_setEnabled(GET_SCRIPT_INT(a));
  1326. RETURN_SCRIPT_VOID;
  1327. }
  1328. scriptVar Layer::script_vcpu_fx_getEnabled(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1329. {
  1330. SCRIPT_FUNCTION_INIT
  1331. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1332. if (l) return MAKE_SCRIPT_INT(l->fx_getEnabled());
  1333. RETURN_SCRIPT_ZERO;
  1334. }
  1335. scriptVar Layer::script_vcpu_fx_setWrap(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a)
  1336. {
  1337. SCRIPT_FUNCTION_INIT
  1338. ASSERT(SOM::isNumeric(&a));
  1339. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1340. if (l) l->fx_setWrap(SOM::makeInt(&a));
  1341. RETURN_SCRIPT_VOID;
  1342. }
  1343. scriptVar Layer::script_vcpu_fx_getWrap(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1344. {
  1345. SCRIPT_FUNCTION_INIT
  1346. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1347. if (l) return MAKE_SCRIPT_INT(l->fx_getWrap());
  1348. RETURN_SCRIPT_ZERO;
  1349. }
  1350. scriptVar Layer::script_vcpu_fx_setRect(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a)
  1351. {
  1352. SCRIPT_FUNCTION_INIT
  1353. ASSERT(SOM::isNumeric(&a));
  1354. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1355. if (l) l->fx_setRect(SOM::makeInt(&a));
  1356. RETURN_SCRIPT_VOID;
  1357. }
  1358. scriptVar Layer::script_vcpu_fx_getRect(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1359. {
  1360. SCRIPT_FUNCTION_INIT
  1361. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1362. if (l) return MAKE_SCRIPT_INT(l->fx_getRect());
  1363. RETURN_SCRIPT_ZERO;
  1364. }
  1365. scriptVar Layer::script_vcpu_fx_setAlphaMode(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a)
  1366. {
  1367. SCRIPT_FUNCTION_INIT
  1368. ASSERT(SOM::isNumeric(&a));
  1369. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1370. if (l) l->fx_setAlphaMode(SOM::makeInt(&a));
  1371. RETURN_SCRIPT_VOID;
  1372. }
  1373. scriptVar Layer::script_vcpu_fx_getAlphaMode(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1374. {
  1375. SCRIPT_FUNCTION_INIT
  1376. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1377. if (l) return MAKE_SCRIPT_INT(l->fx_getAlphaMode());
  1378. RETURN_SCRIPT_ZERO;
  1379. }
  1380. scriptVar Layer::script_vcpu_fx_setBilinear(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a)
  1381. {
  1382. SCRIPT_FUNCTION_INIT
  1383. ASSERT(SOM::isNumeric(&a));
  1384. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1385. if (l) l->fx_setBilinear(SOM::makeInt(&a));
  1386. RETURN_SCRIPT_VOID;
  1387. }
  1388. scriptVar Layer::script_vcpu_fx_getBilinear(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1389. {
  1390. SCRIPT_FUNCTION_INIT
  1391. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1392. if (l) return MAKE_SCRIPT_INT(l->fx_getBilinear());
  1393. RETURN_SCRIPT_ZERO;
  1394. }
  1395. scriptVar Layer::script_vcpu_fx_setBgFx(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a)
  1396. {
  1397. SCRIPT_FUNCTION_INIT
  1398. ASSERT(SOM::isNumeric(&a));
  1399. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1400. if (l) l->fx_setBgFx(SOM::makeInt(&a));
  1401. RETURN_SCRIPT_VOID;
  1402. }
  1403. scriptVar Layer::script_vcpu_fx_getBgFx(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1404. {
  1405. SCRIPT_FUNCTION_INIT
  1406. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1407. if (l) return MAKE_SCRIPT_INT(((Layer *)o)->fx_getBgFx());
  1408. RETURN_SCRIPT_ZERO;
  1409. }
  1410. scriptVar Layer::script_vcpu_fx_setSpeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s)
  1411. {
  1412. SCRIPT_FUNCTION_INIT
  1413. ASSERT(SOM::isNumeric(&s));
  1414. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1415. if (l) l->fx_setSpeed(SOM::makeInt(&s));
  1416. RETURN_SCRIPT_VOID;
  1417. }
  1418. scriptVar Layer::script_vcpu_fx_getSpeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1419. {
  1420. SCRIPT_FUNCTION_INIT
  1421. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1422. if (l) return MAKE_SCRIPT_INT(((Layer *)o)->fx_getSpeed());
  1423. RETURN_SCRIPT_ZERO;
  1424. }
  1425. scriptVar Layer::script_vcpu_fx_setRealtime(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s)
  1426. {
  1427. SCRIPT_FUNCTION_INIT
  1428. ASSERT(SOM::isNumeric(&s));
  1429. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1430. if (l) l->fx_setRealtime(SOM::makeInt(&s));
  1431. RETURN_SCRIPT_VOID;
  1432. }
  1433. scriptVar Layer::script_vcpu_fx_getRealtime(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1434. {
  1435. SCRIPT_FUNCTION_INIT
  1436. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1437. if (l) return MAKE_SCRIPT_INT(((Layer *)o)->fx_getRealtime());
  1438. RETURN_SCRIPT_ZERO;
  1439. }
  1440. scriptVar Layer::script_vcpu_fx_setClear(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s)
  1441. {
  1442. SCRIPT_FUNCTION_INIT
  1443. ASSERT(SOM::isNumeric(&s));
  1444. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1445. if (l) l->fx_setClear(SOM::makeInt(&s));
  1446. RETURN_SCRIPT_VOID;
  1447. }
  1448. scriptVar Layer::script_vcpu_fx_getClear(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1449. {
  1450. SCRIPT_FUNCTION_INIT
  1451. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1452. if (l) return MAKE_SCRIPT_INT(l->fx_getClear());
  1453. RETURN_SCRIPT_ZERO;
  1454. }
  1455. scriptVar Layer::script_vcpu_fx_setLocalized(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s)
  1456. {
  1457. SCRIPT_FUNCTION_INIT
  1458. ASSERT(SOM::isNumeric(&s));
  1459. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1460. if (l) l->fx_setLocalized(SOM::makeInt(&s));
  1461. RETURN_SCRIPT_VOID;
  1462. }
  1463. scriptVar Layer::script_vcpu_fx_getLocalized(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1464. {
  1465. SCRIPT_FUNCTION_INIT
  1466. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1467. if (l) return MAKE_SCRIPT_INT(l->fx_getLocalized());
  1468. RETURN_SCRIPT_ZERO;
  1469. }
  1470. scriptVar Layer::script_vcpu_fx_setGridSize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y)
  1471. {
  1472. SCRIPT_FUNCTION_INIT
  1473. ASSERT(SOM::isNumeric(&x));
  1474. ASSERT(SOM::isNumeric(&y));
  1475. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1476. if (l) l->fx_setGridSize(SOM::makeInt(&x), SOM::makeInt(&y));
  1477. RETURN_SCRIPT_VOID;
  1478. }
  1479. scriptVar Layer::script_vcpu_fx_update(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1480. {
  1481. SCRIPT_FUNCTION_INIT
  1482. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1483. if (l) l->fx_update();
  1484. RETURN_SCRIPT_VOID;
  1485. }
  1486. scriptVar Layer::script_vcpu_fx_restart(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1487. {
  1488. SCRIPT_FUNCTION_INIT
  1489. Layer *l = static_cast<Layer *>(o->vcpu_getInterface(layerGuid));
  1490. if (l) l->fx_restart();
  1491. RETURN_SCRIPT_VOID;
  1492. }
  1493. scriptVar Layer::script_vcpu_fx_onInit(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1494. {
  1495. SCRIPT_FUNCTION_INIT;
  1496. PROCESS_HOOKS0(o, layerController);
  1497. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1498. SCRIPT_EXEC_EVENT0(o);
  1499. }
  1500. scriptVar Layer::script_vcpu_fx_onFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1501. {
  1502. SCRIPT_FUNCTION_INIT;
  1503. PROCESS_HOOKS0(o, layerController);
  1504. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1505. SCRIPT_EXEC_EVENT0(o);
  1506. }
  1507. scriptVar Layer::script_vcpu_fx_onGetPixelA(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r, scriptVar d, scriptVar x, scriptVar y)
  1508. {
  1509. SCRIPT_FUNCTION_INIT;
  1510. PROCESS_HOOKS4(o, layerController, r, d, x, y);
  1511. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1512. SCRIPT_EXEC_EVENT4(o, r, d, x, y);
  1513. }
  1514. scriptVar Layer::script_vcpu_fx_onGetPixelX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r, scriptVar d, scriptVar x, scriptVar y)
  1515. {
  1516. SCRIPT_FUNCTION_INIT;
  1517. PROCESS_HOOKS4(o, layerController, r, d, x, y);
  1518. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1519. SCRIPT_EXEC_EVENT4(o, r, d, x, y);
  1520. }
  1521. scriptVar Layer::script_vcpu_fx_onGetPixelY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r, scriptVar d, scriptVar x, scriptVar y)
  1522. {
  1523. SCRIPT_FUNCTION_INIT;
  1524. PROCESS_HOOKS4(o, layerController, r, d, x, y);
  1525. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1526. SCRIPT_EXEC_EVENT4(o, r, d, x, y);
  1527. }
  1528. scriptVar Layer::script_vcpu_fx_onGetPixelR(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r, scriptVar d, scriptVar x, scriptVar y)
  1529. {
  1530. SCRIPT_FUNCTION_INIT;
  1531. PROCESS_HOOKS4(o, layerController, r, d, x, y);
  1532. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1533. SCRIPT_EXEC_EVENT4(o, r, d, x, y);
  1534. }
  1535. scriptVar Layer::script_vcpu_fx_onGetPixelD(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r, scriptVar d, scriptVar x, scriptVar y)
  1536. {
  1537. SCRIPT_FUNCTION_INIT;
  1538. PROCESS_HOOKS4(o, layerController, r, d, x, y);
  1539. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1540. SCRIPT_EXEC_EVENT4(o, r, d, x, y);
  1541. }
  1542. #endif //WA3COMPATIBILITY || GEN_FF