ui.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812
  1. /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
  2. //
  3. // Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
  4. // All rights reserved.
  5. //
  6. // This file is part of SDLPAL.
  7. //
  8. // SDLPAL is free software: you can redistribute it and/or modify
  9. // it under the terms of the GNU General Public License as published by
  10. // the Free Software Foundation, either version 3 of the License, or
  11. // (at your option) any later version.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU General Public License
  19. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. //
  21. #include "main.h"
  22. LPSPRITE gpSpriteUI = NULL;
  23. INT
  24. PAL_InitUI(
  25. VOID
  26. )
  27. /*++
  28. Purpose:
  29. Initialze the UI subsystem.
  30. Parameters:
  31. None.
  32. Return value:
  33. 0 = success, -1 = fail.
  34. --*/
  35. {
  36. int iSize;
  37. //
  38. // Load the UI sprite.
  39. //
  40. iSize = PAL_MKFGetChunkSize(CHUNKNUM_SPRITEUI, gpGlobals->f.fpDATA);
  41. if (iSize < 0)
  42. {
  43. return -1;
  44. }
  45. gpSpriteUI = (LPSPRITE)calloc(1, iSize);
  46. if (gpSpriteUI == NULL)
  47. {
  48. return -1;
  49. }
  50. PAL_MKFReadChunk(gpSpriteUI, iSize, CHUNKNUM_SPRITEUI, gpGlobals->f.fpDATA);
  51. return 0;
  52. }
  53. VOID
  54. PAL_FreeUI(
  55. VOID
  56. )
  57. /*++
  58. Purpose:
  59. Shutdown the UI subsystem.
  60. Parameters:
  61. None.
  62. Return value:
  63. None.
  64. --*/
  65. {
  66. if (gpSpriteUI != NULL)
  67. {
  68. free(gpSpriteUI);
  69. gpSpriteUI = NULL;
  70. }
  71. }
  72. LPBOX
  73. PAL_CreateBox(
  74. PAL_POS pos,
  75. INT nRows,
  76. INT nColumns,
  77. INT iStyle,
  78. BOOL fSaveScreen
  79. )
  80. /*++
  81. Purpose:
  82. Create a box on the screen.
  83. Parameters:
  84. [IN] pos - position of the box.
  85. [IN] nRows - number of rows of the box.
  86. [IN] nColumns - number of columns of the box.
  87. [IN] iStyle - style of the box (0 or 1).
  88. [IN] fSaveScreen - whether save the used screen area or not.
  89. Return value:
  90. Pointer to a BOX structure. NULL if failed.
  91. If fSaveScreen is false, then always returns NULL.
  92. --*/
  93. {
  94. int i, j, x, m, n;
  95. LPCBITMAPRLE rglpBorderBitmap[3][3];
  96. LPBOX lpBox = NULL;
  97. SDL_Surface *save;
  98. SDL_Rect rect;
  99. //
  100. // Get the bitmaps
  101. //
  102. for (i = 0; i < 3; i++)
  103. {
  104. for (j = 0; j < 3; j++)
  105. {
  106. rglpBorderBitmap[i][j] = PAL_SpriteGetFrame(gpSpriteUI, i * 3 + j + iStyle * 9);
  107. }
  108. }
  109. rect.x = PAL_X(pos);
  110. rect.y = PAL_Y(pos);
  111. rect.w = 0;
  112. rect.h = 0;
  113. //
  114. // Get the total width and total height of the box
  115. //
  116. for (i = 0; i < 3; i++)
  117. {
  118. if (i == 1)
  119. {
  120. rect.w += PAL_RLEGetWidth(rglpBorderBitmap[0][i]) * nColumns;
  121. rect.h += PAL_RLEGetHeight(rglpBorderBitmap[i][0]) * nRows;
  122. }
  123. else
  124. {
  125. rect.w += PAL_RLEGetWidth(rglpBorderBitmap[0][i]);
  126. rect.h += PAL_RLEGetHeight(rglpBorderBitmap[i][0]);
  127. }
  128. }
  129. if (fSaveScreen)
  130. {
  131. //
  132. // Save the used part of the screen
  133. //
  134. save = SDL_CreateRGBSurface(gpScreen->flags, rect.w, rect.h, 8,
  135. gpScreen->format->Rmask, gpScreen->format->Gmask,
  136. gpScreen->format->Bmask, gpScreen->format->Amask);
  137. if (save == NULL)
  138. {
  139. return NULL;
  140. }
  141. lpBox = (LPBOX)calloc(1, sizeof(BOX));
  142. if (lpBox == NULL)
  143. {
  144. SDL_FreeSurface(save);
  145. return NULL;
  146. }
  147. #if SDL_VERSION_ATLEAST(2,0,0)
  148. SDL_SetSurfacePalette(save, gpScreen->format->palette);
  149. #else
  150. SDL_SetPalette(save, SDL_LOGPAL | SDL_PHYSPAL, VIDEO_GetPalette(), 0, 256);
  151. #endif
  152. SDL_BlitSurface(gpScreen, &rect, save, NULL);
  153. lpBox->lpSavedArea = save;
  154. lpBox->pos = pos;
  155. lpBox->wWidth = rect.w;
  156. lpBox->wHeight = rect.h;
  157. }
  158. //
  159. // Border takes 2 additional rows and columns...
  160. //
  161. nRows += 2;
  162. nColumns += 2;
  163. //
  164. // Draw the box
  165. //
  166. for (i = 0; i < nRows; i++)
  167. {
  168. x = rect.x;
  169. m = (i == 0) ? 0 : ((i == nRows - 1) ? 2 : 1);
  170. for (j = 0; j < nColumns; j++)
  171. {
  172. n = (j == 0) ? 0 : ((j == nColumns - 1) ? 2 : 1);
  173. PAL_RLEBlitToSurface(rglpBorderBitmap[m][n], gpScreen, PAL_XY(x, rect.y));
  174. x += PAL_RLEGetWidth(rglpBorderBitmap[m][n]);
  175. }
  176. rect.y += PAL_RLEGetHeight(rglpBorderBitmap[m][0]);
  177. }
  178. return lpBox;
  179. }
  180. LPBOX
  181. PAL_CreateSingleLineBox(
  182. PAL_POS pos,
  183. INT nLen,
  184. BOOL fSaveScreen
  185. )
  186. /*++
  187. Purpose:
  188. Create a single-line box on the screen.
  189. Parameters:
  190. [IN] pos - position of the box.
  191. [IN] nLen - length of the box.
  192. [IN] fSaveScreen - whether save the used screen area or not.
  193. Return value:
  194. Pointer to a BOX structure. NULL if failed.
  195. If fSaveScreen is false, then always returns NULL.
  196. --*/
  197. {
  198. static const int iNumLeftSprite = 44;
  199. static const int iNumMidSprite = 45;
  200. static const int iNumRightSprite = 46;
  201. LPCBITMAPRLE lpBitmapLeft;
  202. LPCBITMAPRLE lpBitmapMid;
  203. LPCBITMAPRLE lpBitmapRight;
  204. SDL_Surface *save;
  205. SDL_Rect rect;
  206. LPBOX lpBox = NULL;
  207. int i;
  208. //
  209. // Get the bitmaps
  210. //
  211. lpBitmapLeft = PAL_SpriteGetFrame(gpSpriteUI, iNumLeftSprite);
  212. lpBitmapMid = PAL_SpriteGetFrame(gpSpriteUI, iNumMidSprite);
  213. lpBitmapRight = PAL_SpriteGetFrame(gpSpriteUI, iNumRightSprite);
  214. rect.x = PAL_X(pos);
  215. rect.y = PAL_Y(pos);
  216. //
  217. // Get the total width and total height of the box
  218. //
  219. rect.w = PAL_RLEGetWidth(lpBitmapLeft) + PAL_RLEGetWidth(lpBitmapRight);
  220. rect.w += PAL_RLEGetWidth(lpBitmapMid) * nLen;
  221. rect.h = PAL_RLEGetHeight(lpBitmapLeft);
  222. if (fSaveScreen)
  223. {
  224. //
  225. // Save the used part of the screen
  226. //
  227. save = SDL_CreateRGBSurface(gpScreen->flags, rect.w, rect.h, 8,
  228. gpScreen->format->Rmask, gpScreen->format->Gmask,
  229. gpScreen->format->Bmask, gpScreen->format->Amask);
  230. if (save == NULL)
  231. {
  232. return NULL;
  233. }
  234. lpBox = (LPBOX)calloc(1, sizeof(BOX));
  235. if (lpBox == NULL)
  236. {
  237. SDL_FreeSurface(gpScreen);
  238. return NULL;
  239. }
  240. #if SDL_VERSION_ATLEAST(2,0,0)
  241. SDL_SetSurfacePalette(save, gpScreen->format->palette);
  242. #else
  243. SDL_SetPalette(save, SDL_PHYSPAL | SDL_LOGPAL, VIDEO_GetPalette(), 0, 256);
  244. #endif
  245. SDL_BlitSurface(gpScreen, &rect, save, NULL);
  246. lpBox->pos = pos;
  247. lpBox->lpSavedArea = save;
  248. lpBox->wHeight = (WORD)rect.w;
  249. lpBox->wWidth = (WORD)rect.h;
  250. }
  251. //
  252. // Draw the box
  253. //
  254. PAL_RLEBlitToSurface(lpBitmapLeft, gpScreen, pos);
  255. rect.x += PAL_RLEGetWidth(lpBitmapLeft);
  256. for (i = 0; i < nLen; i++)
  257. {
  258. PAL_RLEBlitToSurface(lpBitmapMid, gpScreen, PAL_XY(rect.x, rect.y));
  259. rect.x += PAL_RLEGetWidth(lpBitmapMid);
  260. }
  261. PAL_RLEBlitToSurface(lpBitmapRight, gpScreen, PAL_XY(rect.x, rect.y));
  262. return lpBox;
  263. }
  264. VOID
  265. PAL_DeleteBox(
  266. LPBOX lpBox
  267. )
  268. /*++
  269. Purpose:
  270. Delete a box and restore the saved part of the screen.
  271. Parameters:
  272. [IN] lpBox - pointer to the BOX struct.
  273. Return value:
  274. None.
  275. --*/
  276. {
  277. SDL_Rect rect;
  278. //
  279. // Check for NULL pointer.
  280. //
  281. if (lpBox == NULL)
  282. {
  283. return;
  284. }
  285. //
  286. // Restore the saved screen part
  287. //
  288. rect.x = PAL_X(lpBox->pos);
  289. rect.y = PAL_Y(lpBox->pos);
  290. rect.w = lpBox->wWidth;
  291. rect.h = lpBox->wHeight;
  292. SDL_BlitSurface(lpBox->lpSavedArea, NULL, gpScreen, &rect);
  293. //
  294. // Free the memory used by the box
  295. //
  296. SDL_FreeSurface(lpBox->lpSavedArea);
  297. free(lpBox);
  298. }
  299. WORD
  300. PAL_ReadMenu(
  301. LPITEMCHANGED_CALLBACK lpfnMenuItemChanged,
  302. LPMENUITEM rgMenuItem,
  303. INT nMenuItem,
  304. WORD wDefaultItem,
  305. BYTE bLabelColor
  306. )
  307. /*++
  308. Purpose:
  309. Execute a menu.
  310. Parameters:
  311. [IN] lpfnMenuItemChanged - Callback function which is called when user
  312. changed the current menu item.
  313. [IN] rgMenuItem - Array of the menu items.
  314. [IN] nMenuItem - Number of menu items.
  315. [IN] wDefaultItem - default item index.
  316. [IN] bLabelColor - color of the labels.
  317. Return value:
  318. Return value of the selected menu item. MENUITEM_VALUE_CANCELLED if cancelled.
  319. --*/
  320. {
  321. int i;
  322. WORD wCurrentItem = (wDefaultItem < nMenuItem) ? wDefaultItem : 0;
  323. //
  324. // Draw all the menu texts.
  325. //
  326. for (i = 0; i < nMenuItem; i++)
  327. {
  328. BYTE bColor = bLabelColor;
  329. if (!rgMenuItem[i].fEnabled)
  330. {
  331. if (i == wCurrentItem)
  332. {
  333. bColor = MENUITEM_COLOR_SELECTED_INACTIVE;
  334. }
  335. else
  336. {
  337. bColor = MENUITEM_COLOR_INACTIVE;
  338. }
  339. }
  340. PAL_DrawText(PAL_GetWord(rgMenuItem[i].wNumWord), rgMenuItem[i].pos,
  341. bColor, TRUE, TRUE);
  342. }
  343. if (lpfnMenuItemChanged != NULL)
  344. {
  345. (*lpfnMenuItemChanged)(rgMenuItem[wDefaultItem].wValue);
  346. }
  347. while (TRUE)
  348. {
  349. PAL_ClearKeyState();
  350. //
  351. // Redraw the selected item if needed.
  352. //
  353. if (rgMenuItem[wCurrentItem].fEnabled)
  354. {
  355. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  356. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED, FALSE, TRUE);
  357. }
  358. PAL_ProcessEvent();
  359. if (g_InputState.dwKeyPress & (kKeyDown | kKeyRight))
  360. {
  361. //
  362. // User pressed the down or right arrow key
  363. //
  364. if (rgMenuItem[wCurrentItem].fEnabled)
  365. {
  366. //
  367. // Dehighlight the unselected item.
  368. //
  369. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  370. rgMenuItem[wCurrentItem].pos, bLabelColor, FALSE, TRUE);
  371. }
  372. else
  373. {
  374. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  375. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_INACTIVE, FALSE, TRUE);
  376. }
  377. wCurrentItem++;
  378. if (wCurrentItem >= nMenuItem)
  379. {
  380. wCurrentItem = 0;
  381. }
  382. //
  383. // Highlight the selected item.
  384. //
  385. if (rgMenuItem[wCurrentItem].fEnabled)
  386. {
  387. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  388. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED, FALSE, TRUE);
  389. }
  390. else
  391. {
  392. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  393. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED_INACTIVE, FALSE, TRUE);
  394. }
  395. if (lpfnMenuItemChanged != NULL)
  396. {
  397. (*lpfnMenuItemChanged)(rgMenuItem[wCurrentItem].wValue);
  398. }
  399. }
  400. else if (g_InputState.dwKeyPress & (kKeyUp | kKeyLeft))
  401. {
  402. //
  403. // User pressed the up or left arrow key
  404. //
  405. if (rgMenuItem[wCurrentItem].fEnabled)
  406. {
  407. //
  408. // Dehighlight the unselected item.
  409. //
  410. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  411. rgMenuItem[wCurrentItem].pos, bLabelColor, FALSE, TRUE);
  412. }
  413. else
  414. {
  415. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  416. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_INACTIVE, FALSE, TRUE);
  417. }
  418. if (wCurrentItem > 0)
  419. {
  420. wCurrentItem--;
  421. }
  422. else
  423. {
  424. wCurrentItem = nMenuItem - 1;
  425. }
  426. //
  427. // Highlight the selected item.
  428. //
  429. if (rgMenuItem[wCurrentItem].fEnabled)
  430. {
  431. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  432. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED, FALSE, TRUE);
  433. }
  434. else
  435. {
  436. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  437. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED_INACTIVE, FALSE, TRUE);
  438. }
  439. if (lpfnMenuItemChanged != NULL)
  440. {
  441. (*lpfnMenuItemChanged)(rgMenuItem[wCurrentItem].wValue);
  442. }
  443. }
  444. else if (g_InputState.dwKeyPress & kKeyMenu)
  445. {
  446. //
  447. // User cancelled
  448. //
  449. if (rgMenuItem[wCurrentItem].fEnabled)
  450. {
  451. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  452. rgMenuItem[wCurrentItem].pos, bLabelColor, FALSE, TRUE);
  453. }
  454. else
  455. {
  456. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  457. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_INACTIVE, FALSE, TRUE);
  458. }
  459. break;
  460. }
  461. else if (g_InputState.dwKeyPress & kKeySearch)
  462. {
  463. //
  464. // User pressed Enter
  465. //
  466. if (rgMenuItem[wCurrentItem].fEnabled)
  467. {
  468. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  469. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_CONFIRMED, FALSE, TRUE);
  470. return rgMenuItem[wCurrentItem].wValue;
  471. }
  472. }
  473. //
  474. // Use delay function to avoid high CPU usage.
  475. //
  476. SDL_Delay(50);
  477. }
  478. return MENUITEM_VALUE_CANCELLED;
  479. }
  480. VOID
  481. PAL_DrawNumber(
  482. UINT iNum,
  483. UINT nLength,
  484. PAL_POS pos,
  485. NUMCOLOR color,
  486. NUMALIGN align
  487. )
  488. /*++
  489. Purpose:
  490. Draw the specified number with the bitmaps in the UI sprite.
  491. Parameters:
  492. [IN] iNum - the number to be drawn.
  493. [IN] nLength - max. length of the number.
  494. [IN] pos - position on the screen.
  495. [IN] color - color of the number (yellow or blue).
  496. [IN] align - align mode of the number.
  497. Return value:
  498. None.
  499. --*/
  500. {
  501. UINT nActualLength, i;
  502. int x, y;
  503. LPCBITMAPRLE rglpBitmap[10];
  504. //
  505. // Get the bitmaps. Blue starts from 29, Cyan from 56, Yellow from 19.
  506. //
  507. x = (color == kNumColorBlue) ? 29 : ((color == kNumColorCyan) ? 56 : 19);
  508. for (i = 0; i < 10; i++)
  509. {
  510. rglpBitmap[i] = PAL_SpriteGetFrame(gpSpriteUI, (UINT)x + i);
  511. }
  512. i = iNum;
  513. nActualLength = 0;
  514. //
  515. // Calculate the actual length of the number.
  516. //
  517. while (i > 0)
  518. {
  519. i /= 10;
  520. nActualLength++;
  521. }
  522. if (nActualLength > nLength)
  523. {
  524. nActualLength = nLength;
  525. }
  526. else if (nActualLength == 0)
  527. {
  528. nActualLength = 1;
  529. }
  530. x = PAL_X(pos) - 6;
  531. y = PAL_Y(pos);
  532. switch (align)
  533. {
  534. case kNumAlignLeft:
  535. x += 6 * nActualLength;
  536. break;
  537. case kNumAlignMid:
  538. x += 3 * (nLength + nActualLength);
  539. break;
  540. case kNumAlignRight:
  541. x += 6 * nLength;
  542. break;
  543. }
  544. //
  545. // Draw the number.
  546. //
  547. while (nActualLength-- > 0)
  548. {
  549. PAL_RLEBlitToSurface(rglpBitmap[iNum % 10], gpScreen, PAL_XY(x, y));
  550. x -= 6;
  551. iNum /= 10;
  552. }
  553. }
  554. #ifndef PAL_WIN95
  555. LPOBJECTDESC
  556. PAL_LoadObjectDesc(
  557. LPCSTR lpszFileName
  558. )
  559. /*++
  560. Purpose:
  561. Load the object description strings from file.
  562. Parameters:
  563. [IN] lpszFileName - the filename to be loaded.
  564. Return value:
  565. Pointer to loaded data, in linked list form. NULL if unable to load.
  566. --*/
  567. {
  568. FILE *fp;
  569. PAL_LARGE char buf[512];
  570. char *p;
  571. LPOBJECTDESC lpDesc = NULL, pNew = NULL;
  572. unsigned int i;
  573. fp = fopen(lpszFileName, "r");
  574. if (fp == NULL)
  575. {
  576. return NULL;
  577. }
  578. //
  579. // Load the description data
  580. //
  581. while (fgets(buf, 512, fp) != NULL)
  582. {
  583. p = strchr(buf, '=');
  584. if (p == NULL)
  585. {
  586. continue;
  587. }
  588. *p = '\0';
  589. p++;
  590. pNew = UTIL_calloc(1, sizeof(OBJECTDESC));
  591. sscanf(buf, "%x", &i);
  592. pNew->wObjectID = i;
  593. pNew->lpDesc = strdup(p);
  594. pNew->next = lpDesc;
  595. lpDesc = pNew;
  596. }
  597. fclose(fp);
  598. return lpDesc;
  599. }
  600. VOID
  601. PAL_FreeObjectDesc(
  602. LPOBJECTDESC lpObjectDesc
  603. )
  604. /*++
  605. Purpose:
  606. Free the object description data.
  607. Parameters:
  608. [IN] lpObjectDesc - the description data to be freed.
  609. Return value:
  610. None.
  611. --*/
  612. {
  613. LPOBJECTDESC p;
  614. while (lpObjectDesc != NULL)
  615. {
  616. p = lpObjectDesc->next;
  617. free(lpObjectDesc->lpDesc);
  618. free(lpObjectDesc);
  619. lpObjectDesc = p;
  620. }
  621. }
  622. LPCSTR
  623. PAL_GetObjectDesc(
  624. LPOBJECTDESC lpObjectDesc,
  625. WORD wObjectID
  626. )
  627. /*++
  628. Purpose:
  629. Get the object description string from the linked list.
  630. Parameters:
  631. [IN] lpObjectDesc - the description data linked list.
  632. [IN] wObjectID - the object ID.
  633. Return value:
  634. The description string. NULL if the specified object ID
  635. is not found.
  636. --*/
  637. {
  638. while (lpObjectDesc != NULL)
  639. {
  640. if (lpObjectDesc->wObjectID == wObjectID)
  641. {
  642. return lpObjectDesc->lpDesc;
  643. }
  644. lpObjectDesc = lpObjectDesc->next;
  645. }
  646. return NULL;
  647. }
  648. #endif