W3DPushButton.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: W3DPushButton.cpp ////////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Westwood Studios Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2001 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // Project: RTS3
  34. //
  35. // File name: W3DPushButton.cpp
  36. //
  37. // Created: Colin Day, June 2001
  38. //
  39. // Desc: W3D implementation for the push button control element
  40. //
  41. //-----------------------------------------------------------------------------
  42. ///////////////////////////////////////////////////////////////////////////////
  43. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  44. #include <stdlib.h>
  45. // USER INCLUDES //////////////////////////////////////////////////////////////
  46. #include "GameClient/Gadget.h"
  47. #include "GameClient/GameWindowGlobal.h"
  48. #include "GameClient/GameWindowManager.h"
  49. #include "GameClient/GadgetPushButton.h"
  50. #include "GameClient/Display.h"
  51. #include "W3DDevice/GameClient/W3DGameWindow.h"
  52. #include "W3DDevice/GameClient/W3DDisplay.h"
  53. #include "W3DDevice/GameClient/W3DGadget.h"
  54. #ifdef _INTERNAL
  55. // for occasional debugging...
  56. //#pragma optimize("", off)
  57. //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
  58. #endif
  59. // DEFINES ////////////////////////////////////////////////////////////////////
  60. // PRIVATE TYPES //////////////////////////////////////////////////////////////
  61. // PRIVATE DATA ///////////////////////////////////////////////////////////////
  62. // PUBLIC DATA ////////////////////////////////////////////////////////////////
  63. // PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
  64. void W3DGadgetPushButtonImageDrawThree(GameWindow *window, WinInstanceData *instData );
  65. void W3DGadgetPushButtonImageDrawOne(GameWindow *window, WinInstanceData *instData );
  66. // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
  67. // drawButtonText =============================================================
  68. /** Draw button text to the screen */
  69. //=============================================================================
  70. static void drawButtonText( GameWindow *window, WinInstanceData *instData )
  71. {
  72. ICoord2D origin, size, textPos;
  73. Int width, height;
  74. Color textColor, dropColor;
  75. DisplayString *text = instData->getTextDisplayString();
  76. // sanity
  77. if( text == NULL || text->getTextLength() == 0 )
  78. return;
  79. // get window position and size
  80. window->winGetScreenPosition( &origin.x, &origin.y );
  81. window->winGetSize( &size.x, &size.y );
  82. // set whether or not we center the wrapped text
  83. text->setWordWrapCentered( BitTest( instData->getStatus(), WIN_STATUS_WRAP_CENTERED ));
  84. text->setWordWrap(size.x);
  85. // get the right text color
  86. if( BitTest( window->winGetStatus(), WIN_STATUS_ENABLED ) == FALSE )
  87. {
  88. textColor = window->winGetDisabledTextColor();
  89. dropColor = window->winGetDisabledTextBorderColor();
  90. } // end if, disabled
  91. else if( BitTest( instData->getState(), WIN_STATE_HILITED ) )
  92. {
  93. textColor = window->winGetHiliteTextColor();
  94. dropColor = window->winGetHiliteTextBorderColor();
  95. } // end else if, hilited
  96. else
  97. {
  98. textColor = window->winGetEnabledTextColor();
  99. dropColor = window->winGetEnabledTextBorderColor();
  100. } // end enabled only
  101. // set our font to that of our parent if not the same
  102. if( text->getFont() != window->winGetFont() )
  103. text->setFont( window->winGetFont() );
  104. // get text size
  105. text->getSize( &width, &height );
  106. // where to draw
  107. textPos.x = origin.x + (size.x / 2) - (width / 2);
  108. textPos.y = origin.y + (size.y / 2) - (height / 2);
  109. // draw it
  110. text->draw( textPos.x, textPos.y, textColor, dropColor );
  111. } // end drawButtonText
  112. ///////////////////////////////////////////////////////////////////////////////
  113. // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
  114. ///////////////////////////////////////////////////////////////////////////////
  115. // W3DGadgetPushButtonDraw ====================================================
  116. /** Draw colored pushbutton using standard graphics */
  117. //=============================================================================
  118. void W3DGadgetPushButtonDraw( GameWindow *window, WinInstanceData *instData )
  119. {
  120. Color color, border;
  121. ICoord2D origin, size, start, end;
  122. // get window position and size
  123. window->winGetScreenPosition( &origin.x, &origin.y );
  124. window->winGetSize( &size.x, &size.y );
  125. //
  126. // get pointer to image we want to draw depending on our state,
  127. // see GadgetPushButton.h for info
  128. //
  129. if( BitTest( window->winGetStatus(), WIN_STATUS_ENABLED ) == FALSE )
  130. {
  131. if( BitTest( instData->getState(), WIN_STATE_SELECTED ) )
  132. {
  133. color = GadgetButtonGetDisabledSelectedColor( window );
  134. border = GadgetButtonGetDisabledSelectedBorderColor( window );
  135. }
  136. else
  137. {
  138. color = GadgetButtonGetDisabledColor( window );
  139. border = GadgetButtonGetDisabledBorderColor( window );
  140. }
  141. } // end if, disabled
  142. else if( BitTest( instData->getState(), WIN_STATE_HILITED ) )
  143. {
  144. if( BitTest( instData->getState(), WIN_STATE_SELECTED ) )
  145. {
  146. color = GadgetButtonGetHiliteSelectedColor( window );
  147. border = GadgetButtonGetHiliteSelectedBorderColor( window );
  148. }
  149. else
  150. {
  151. color = GadgetButtonGetHiliteColor( window );
  152. border = GadgetButtonGetHiliteBorderColor( window );
  153. }
  154. } // end else if, hilited and enabled
  155. else
  156. {
  157. if( BitTest( instData->getState(), WIN_STATE_SELECTED ) )
  158. {
  159. color = GadgetButtonGetEnabledSelectedColor( window );
  160. border = GadgetButtonGetEnabledSelectedBorderColor( window );
  161. }
  162. else
  163. {
  164. color = GadgetButtonGetEnabledColor( window );
  165. border = GadgetButtonGetEnabledBorderColor( window );
  166. }
  167. } // end else, enabled only
  168. // compute draw position
  169. start.x = origin.x;
  170. start.y = origin.y;
  171. end.x = start.x + size.x;
  172. end.y = start.y + size.y;
  173. // box and border
  174. if( border != WIN_COLOR_UNDEFINED )
  175. {
  176. TheWindowManager->winOpenRect( border, WIN_DRAW_LINE_WIDTH,
  177. start.x, start.y, end.x, end.y );
  178. } // end if
  179. if( color != WIN_COLOR_UNDEFINED )
  180. {
  181. // draw inside border
  182. start.x++;
  183. start.y++;
  184. end.x--;
  185. end.y--;
  186. TheWindowManager->winFillRect( color, WIN_DRAW_LINE_WIDTH,
  187. start.x, start.y, end.x, end.y );
  188. } // end if
  189. // draw the button text
  190. if( instData->getTextLength() )
  191. drawButtonText( window, instData );
  192. // if we have a video buffer, draw the video buffer
  193. if ( instData->m_videoBuffer )
  194. {
  195. TheDisplay->drawVideoBuffer( instData->m_videoBuffer, origin.x, origin.y, origin.x + size.x, origin.y + size.y );
  196. }
  197. PushButtonData *pData = (PushButtonData *)window->winGetUserData();
  198. if( pData )
  199. {
  200. if( pData->overlayImage )
  201. {
  202. //Render the overlay image now.
  203. TheDisplay->drawImage( pData->overlayImage, origin.x, origin.y, origin.x + size.x, origin.y + size.y );
  204. }
  205. if( pData->drawClock )
  206. {
  207. if( pData->drawClock == NORMAL_CLOCK )
  208. {
  209. TheDisplay->drawRectClock(origin.x, origin.y, size.x, size.y, pData->percentClock,pData->colorClock);
  210. }
  211. else if( pData->drawClock == INVERSE_CLOCK )
  212. {
  213. TheDisplay->drawRemainingRectClock( origin.x, origin.y, size.x, size.y, pData->percentClock,pData->colorClock );
  214. }
  215. pData->drawClock = NO_CLOCK;
  216. window->winSetUserData(pData);
  217. }
  218. if( pData->drawBorder && pData->colorBorder != GAME_COLOR_UNDEFINED )
  219. {
  220. TheDisplay->drawOpenRect(origin.x -1, origin.y - 1, size.x + 2, size.y + 2,1 , pData->colorBorder);
  221. }
  222. }
  223. } // end W3DGadgetPushButtonDraw
  224. // W3DGadgetPushButtonImageDraw ===============================================
  225. /** Draw pushbutton with user supplied images */
  226. //=============================================================================
  227. void W3DGadgetPushButtonImageDraw( GameWindow *window,
  228. WinInstanceData *instData )
  229. {
  230. // if we return NULL then we'll call the one picture drawing code, if we return a value
  231. // then we'll call the 3 picture drawing code
  232. if( GadgetButtonGetMiddleEnabledImage( window ) )
  233. {
  234. if( BitTest( instData->getState(), WIN_STATUS_USE_OVERLAY_STATES ) )
  235. {
  236. ICoord2D size, start;
  237. // get window position
  238. window->winGetScreenPosition( &start.x, &start.y );
  239. window->winGetSize( &size.x, &size.y );
  240. // offset position by image offset
  241. start.x += instData->m_imageOffset.x;
  242. start.y += instData->m_imageOffset.y;
  243. DEBUG_CRASH( ("Button at %d,%d is attempting to render with W3DGadgetPushButtonImageDrawThree(), but is using overlay states! Forcing the code to use W3DGadgetPushButtonImageDrawOne() instead.", start.x, start.y ) );
  244. W3DGadgetPushButtonImageDrawOne( window, instData );
  245. }
  246. else
  247. {
  248. W3DGadgetPushButtonImageDrawThree( window, instData );
  249. }
  250. }
  251. else
  252. {
  253. W3DGadgetPushButtonImageDrawOne( window, instData );
  254. }
  255. }
  256. void W3DGadgetPushButtonImageDrawOne( GameWindow *window,
  257. WinInstanceData *instData )
  258. {
  259. const Image *image = NULL;
  260. ICoord2D size, start, end;
  261. //
  262. // get pointer to image we want to draw depending on our state,
  263. // see GadgetPushButton.h for info
  264. //
  265. image = GadgetButtonGetEnabledImage( window );
  266. if( !BitTest( window->winGetStatus(), WIN_STATUS_USE_OVERLAY_STATES ) )
  267. {
  268. //Certain buttons have the option to specify specific images for
  269. //altered states. If they do, then we won't render the auto-overlay versions.
  270. if( BitTest( window->winGetStatus(), WIN_STATUS_ENABLED ) == FALSE )
  271. {
  272. if( BitTest( instData->getState(), WIN_STATE_SELECTED ) )
  273. image = GadgetButtonGetDisabledSelectedImage( window );
  274. else
  275. image = GadgetButtonGetDisabledImage( window );
  276. } // end if, disabled
  277. else if( BitTest( instData->getState(), WIN_STATE_HILITED ) )
  278. {
  279. if( BitTest( instData->getState(), WIN_STATE_SELECTED ) )
  280. image = GadgetButtonGetHiliteSelectedImage( window );
  281. else
  282. image = GadgetButtonGetHiliteImage( window );
  283. } // end else if, hilited and enabled
  284. else
  285. {
  286. if( BitTest( instData->getState(), WIN_STATE_SELECTED ) )
  287. image = GadgetButtonGetHiliteSelectedImage( window );
  288. } // end else, enabled only
  289. }
  290. // draw the image
  291. if( image )
  292. {
  293. // get window position
  294. window->winGetScreenPosition( &start.x, &start.y );
  295. window->winGetSize( &size.x, &size.y );
  296. // offset position by image offset
  297. start.x += instData->m_imageOffset.x;
  298. start.y += instData->m_imageOffset.y;
  299. // find end point
  300. end.x = start.x + size.x;
  301. end.y = start.y + size.y;
  302. Display::DrawImageMode drawMode=Display::DRAW_IMAGE_ALPHA;
  303. Int colorMultiplier = 0xffffffff;
  304. if(BitTest( window->winGetStatus(), WIN_STATUS_USE_OVERLAY_STATES ) )
  305. {
  306. //we're using a new drawing system which does "grayscale" disabled buttons using original color artwork.
  307. if( !BitTest( window->winGetStatus(), WIN_STATUS_ENABLED ) )
  308. {
  309. if( !BitTest( window->winGetStatus(), WIN_STATUS_NOT_READY ) )
  310. {
  311. //The button is disabled -- but if the button isn't "ready", we don't want to do this because
  312. //we want to show the button in color with just the clock overlay.
  313. if( !BitTest( window->winGetStatus(), WIN_STATUS_ALWAYS_COLOR ) )
  314. {
  315. drawMode=Display::DRAW_IMAGE_GRAYSCALE;
  316. }
  317. else
  318. {
  319. colorMultiplier = 0xff909090; //RGB values are 144/255 (90) -- Alpha is opaque (ff) --> ff909090;
  320. }
  321. }
  322. }
  323. }
  324. TheDisplay->drawImage( image, start.x, start.y, end.x, end.y, colorMultiplier, drawMode );
  325. } // end if
  326. // draw the button text
  327. if( instData->getTextLength() )
  328. drawButtonText( window, instData );
  329. // get window position
  330. window->winGetScreenPosition( &start.x, &start.y );
  331. window->winGetSize( &size.x, &size.y );
  332. // if we have a video buffer, draw the video buffer
  333. if ( instData->m_videoBuffer )
  334. {
  335. TheDisplay->drawVideoBuffer( instData->m_videoBuffer, start.x, start.y, start.x + size.x, start.y + size.y );
  336. }
  337. PushButtonData *pData = (PushButtonData *)window->winGetUserData();
  338. if( pData )
  339. {
  340. if( pData->overlayImage )
  341. {
  342. //Render the overlay image now.
  343. TheDisplay->drawImage( pData->overlayImage, start.x, start.y, start.x + size.x, start.y + size.y );
  344. }
  345. if( pData->drawClock )
  346. {
  347. if( pData->drawClock == NORMAL_CLOCK )
  348. {
  349. TheDisplay->drawRectClock(start.x, start.y, size.x, size.y, pData->percentClock,pData->colorClock);
  350. }
  351. else if( pData->drawClock == INVERSE_CLOCK )
  352. {
  353. TheDisplay->drawRemainingRectClock( start.x, start.y, size.x, size.y, pData->percentClock,pData->colorClock );
  354. }
  355. pData->drawClock = NO_CLOCK;
  356. window->winSetUserData(pData);
  357. }
  358. if( pData->drawBorder && pData->colorBorder != GAME_COLOR_UNDEFINED )
  359. {
  360. TheDisplay->drawOpenRect(start.x - 1, start.y - 1, size.x + 2, size.y + 2, 1, pData->colorBorder);
  361. }
  362. }
  363. //Now render overlays that pertain to the correct state.
  364. if( BitTest( window->winGetStatus(), WIN_STATUS_FLASHING ) )
  365. {
  366. //Handle cameo flashing (let the flashing stack with overlay states)
  367. static const Image *hilitedOverlayIcon = TheMappedImageCollection->findImageByName( "Cameo_push" );
  368. TheDisplay->drawImage( hilitedOverlayIcon, start.x, start.y, start.x + size.x, start.y + size.y );
  369. }
  370. if( BitTest( window->winGetStatus(), WIN_STATUS_USE_OVERLAY_STATES ) )
  371. {
  372. image = NULL;
  373. static const Image *pushedOverlayIcon = TheMappedImageCollection->findImageByName( "Cameo_push" );
  374. static const Image *hilitedOverlayIcon = TheMappedImageCollection->findImageByName( "Cameo_hilited" );
  375. if( pushedOverlayIcon && hilitedOverlayIcon )
  376. {
  377. if(BitTest(window->winGetStatus(), WIN_STATUS_ENABLED))
  378. {
  379. if (BitTest( instData->getState(), WIN_STATE_HILITED ))
  380. {
  381. if( BitTest( instData->getState(), WIN_STATE_SELECTED ) )
  382. {
  383. //The button is hilited and pushed
  384. TheDisplay->drawImage( pushedOverlayIcon, start.x, start.y, start.x + size.x, start.y + size.y );
  385. }
  386. else
  387. {
  388. //The button is hilited
  389. TheDisplay->drawImage( hilitedOverlayIcon, start.x, start.y, start.x + size.x, start.y + size.y );
  390. }
  391. }
  392. else if( BitTest( instData->getState(), WIN_STATE_SELECTED ) )
  393. {
  394. //The button appears to be pushed -- CHECK_LIKE buttons that are on.
  395. TheDisplay->drawImage( pushedOverlayIcon, start.x, start.y, start.x + size.x, start.y + size.y );
  396. }
  397. }
  398. }
  399. }
  400. } // end W3DGadgetPushButtonImageDraw
  401. void W3DGadgetPushButtonImageDrawThree(GameWindow *window, WinInstanceData *instData )
  402. {
  403. const Image *leftImage, *rightImage, *centerImage;
  404. ICoord2D origin, size, start, end;
  405. Int xOffset, yOffset;
  406. Int i;
  407. // get screen position and size
  408. window->winGetScreenPosition( &origin.x, &origin.y );
  409. window->winGetSize( &size.x, &size.y );
  410. // get image offset
  411. xOffset = instData->m_imageOffset.x;
  412. yOffset = instData->m_imageOffset.y;
  413. //
  414. // get pointer to image we want to draw depending on our state,
  415. // see GadgetPushButton.h for info
  416. //
  417. if( BitTest( window->winGetStatus(), WIN_STATUS_ENABLED ) == FALSE )
  418. {
  419. if( BitTest( instData->getState(), WIN_STATE_SELECTED ) )
  420. {
  421. leftImage = GadgetButtonGetLeftDisabledSelectedImage( window );
  422. rightImage = GadgetButtonGetRightDisabledSelectedImage( window );
  423. centerImage = GadgetButtonGetMiddleDisabledSelectedImage( window );
  424. }
  425. else
  426. {
  427. leftImage = GadgetButtonGetLeftDisabledImage( window );
  428. rightImage = GadgetButtonGetRightDisabledImage( window );
  429. centerImage = GadgetButtonGetMiddleDisabledImage( window );
  430. }
  431. } // end if, disabled
  432. else if( BitTest( instData->getState(), WIN_STATE_HILITED ) )
  433. {
  434. if( BitTest( instData->getState(), WIN_STATE_SELECTED ) )
  435. {
  436. leftImage = GadgetButtonGetLeftHiliteSelectedImage( window );
  437. rightImage = GadgetButtonGetRightHiliteSelectedImage( window );
  438. centerImage = GadgetButtonGetMiddleHiliteSelectedImage( window );
  439. }
  440. else
  441. {
  442. leftImage = GadgetButtonGetLeftHiliteImage( window );
  443. rightImage = GadgetButtonGetRightHiliteImage( window );
  444. centerImage = GadgetButtonGetMiddleHiliteImage( window );
  445. }
  446. } // end else if, hilited and enabled
  447. else
  448. {
  449. if( BitTest( instData->getState(), WIN_STATE_SELECTED ) )
  450. {
  451. leftImage = GadgetButtonGetLeftEnabledSelectedImage( window );
  452. rightImage = GadgetButtonGetRightEnabledSelectedImage( window );
  453. centerImage = GadgetButtonGetMiddleEnabledSelectedImage( window );
  454. }
  455. else
  456. {
  457. leftImage = GadgetButtonGetLeftEnabledImage( window );
  458. rightImage = GadgetButtonGetRightEnabledImage( window );
  459. centerImage = GadgetButtonGetMiddleEnabledImage( window );
  460. }
  461. } // end else, enabled only
  462. // sanity, we need to have these images to make it look right
  463. if( leftImage == NULL || rightImage == NULL ||
  464. centerImage == NULL )
  465. return;
  466. // get image sizes for the ends
  467. ICoord2D leftSize, rightSize;
  468. leftSize.x = leftImage->getImageWidth();
  469. leftSize.y = leftImage->getImageHeight();
  470. rightSize.x = rightImage->getImageWidth();
  471. rightSize.y = rightImage->getImageHeight();
  472. // get two key points used in the end drawing
  473. ICoord2D leftEnd, rightStart;
  474. leftEnd.x = origin.x + leftSize.x + xOffset;
  475. leftEnd.y = origin.y + size.y + yOffset;
  476. rightStart.x = origin.x + size.x - rightSize.x + xOffset;
  477. rightStart.y = origin.y + yOffset;
  478. // draw the center repeating bar
  479. Int centerWidth, pieces;
  480. // get width we have to draw our repeating center in
  481. centerWidth = rightStart.x - leftEnd.x;
  482. if( centerWidth <= 0)
  483. {
  484. // draw left end
  485. start.x = origin.x + xOffset;
  486. start.y = origin.y + yOffset;
  487. end.y = leftEnd.y;
  488. end.x = origin.x + xOffset + size.x/2;
  489. TheWindowManager->winDrawImage(leftImage, start.x, start.y, end.x, end.y);
  490. // draw right end
  491. start.y = rightStart.y;
  492. start.x = end.x;
  493. end.x = origin.x + size.x;
  494. end.y = start.y + size.y;
  495. TheWindowManager->winDrawImage(rightImage, start.x, start.y, end.x, end.y);
  496. }
  497. else
  498. {
  499. // how many whole repeating pieces will fit in that width
  500. pieces = centerWidth / centerImage->getImageWidth();
  501. // draw the pieces
  502. start.x = leftEnd.x;
  503. start.y = origin.y + yOffset;
  504. end.y = start.y + size.y + yOffset; //centerImage->getImageHeight() + yOffset;
  505. for( i = 0; i < pieces; i++ )
  506. {
  507. end.x = start.x + centerImage->getImageWidth();
  508. TheWindowManager->winDrawImage( centerImage,
  509. start.x, start.y,
  510. end.x, end.y );
  511. start.x += centerImage->getImageWidth();
  512. } // end for i
  513. // we will draw the image but clip the parts we don't want to show
  514. IRegion2D reg;
  515. reg.lo.x = start.x;
  516. reg.lo.y = start.y;
  517. reg.hi.x = rightStart.x;
  518. reg.hi.y = end.y;
  519. centerWidth = rightStart.x - start.x;
  520. if( centerWidth > 0)
  521. {
  522. TheDisplay->setClipRegion(&reg);
  523. end.x = start.x + centerImage->getImageWidth();
  524. TheWindowManager->winDrawImage( centerImage,
  525. start.x, start.y,
  526. end.x, end.y );
  527. TheDisplay->enableClipping(FALSE);
  528. }
  529. // draw left end
  530. start.x = origin.x + xOffset;
  531. start.y = origin.y + yOffset;
  532. end = leftEnd;
  533. TheWindowManager->winDrawImage(leftImage, start.x, start.y, end.x, end.y);
  534. // draw right end
  535. start = rightStart;
  536. end.x = start.x + rightSize.x;
  537. end.y = start.y + size.y;
  538. TheWindowManager->winDrawImage(rightImage, start.x, start.y, end.x, end.y);
  539. }
  540. // draw the button text
  541. if( instData->getTextLength() )
  542. drawButtonText( window, instData );
  543. // get window position
  544. window->winGetScreenPosition( &start.x, &start.y );
  545. window->winGetSize( &size.x, &size.y );
  546. // if we have a video buffer, draw the video buffer
  547. if ( instData->m_videoBuffer )
  548. {
  549. TheDisplay->drawVideoBuffer( instData->m_videoBuffer, start.x, start.y, start.x + size.x, start.y + size.y );
  550. }
  551. PushButtonData *pData = (PushButtonData *)window->winGetUserData();
  552. if( pData )
  553. {
  554. if( pData->overlayImage )
  555. {
  556. //Render the overlay image now.
  557. TheDisplay->drawImage( pData->overlayImage, origin.x, origin.y, origin.x + size.x, origin.y + size.y );
  558. }
  559. if( pData->drawClock )
  560. {
  561. if( pData->drawClock == NORMAL_CLOCK )
  562. {
  563. TheDisplay->drawRectClock(start.x, start.y, size.x, size.y, pData->percentClock,pData->colorClock);
  564. }
  565. else if( pData->drawClock == INVERSE_CLOCK )
  566. {
  567. TheDisplay->drawRemainingRectClock( start.x, start.y, size.x, size.y, pData->percentClock,pData->colorClock );
  568. }
  569. pData->drawClock = NO_CLOCK;
  570. window->winSetUserData(pData);
  571. }
  572. if( pData->drawBorder && pData->colorBorder != GAME_COLOR_UNDEFINED )
  573. {
  574. TheDisplay->drawOpenRect(start.x - 1, start.y - 1, size.x + 2, size.y + 2, 1, pData->colorBorder);
  575. }
  576. }
  577. }